• Xamarin.Android 上中下布局


    xml代码:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <!--上半部分-->
        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="120dp"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:id="@+id/relativeLayoutTop">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal"
                android:background="#cccccc">
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="上半部分"
                    android:textColor="#FFFFFF"
                    android:textSize="20dp"
                    android:gravity="center_horizontal" />
            </LinearLayout>
        </RelativeLayout>
    <!--下半部分-->
        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:layout_alignParentBottom="true"
            android:id="@+id/relativeLayoutBottom">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal"
                android:background="#888888">
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="下半部分"
                    android:textColor="#000000"
                    android:textSize="20dp"
                    android:gravity="center_horizontal" />
            </LinearLayout>
        </RelativeLayout>
    <!--中间部分-->
        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/relativeLayoutTop"
            android:id="@+id/relativeLayoutCenter"
            android:layout_above="@id/relativeLayoutBottom">
          <HorizontalScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#ffffff">
              <TextView
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:text="中间部分"
                  android:textColor="#000000"
                  android:textSize="20dp"
                  android:gravity="center_horizontal" />
            </LinearLayout>
          </HorizontalScrollView>
        </RelativeLayout>
    </RelativeLayout>

    效果图:

    RelativeLayout 中主要属性

    android:layout_above="@id/xxx"        –将控件置于给定ID控件之上
    android:layout_below="@id/xxx"        –将控件置于给定ID控件之下

    android:layout_toLeftOf="@id/xxx"          –将控件的右边缘和给定ID控件的左边缘对齐
    android:layout_toRightOf="@id/xxx"       –将控件的左边缘和给定ID控件的右边缘对齐

    android:layout_alignLeft="@id/xxx"                  –将控件的左边缘和给定ID控件的左边缘对齐
    android:layout_alignTop="@id/xxx"                  –将控件的上边缘和给定ID控件的上边缘对齐
    android:layout_alignRight="@id/xxx"               –将控件的右边缘和给定ID控件的右边缘对齐
    android:layout_alignBottom="@id/xxx"            –将控件的底边缘和给定ID控件的底边缘对齐
    android:layout_alignParentLeft="true"              –将控件的左边缘和父控件的左边缘对齐
    android:layout_alignParentTop="true"              –将控件的上边缘和父控件的上边缘对齐
    android:layout_alignParentRight="true"            –将控件的右边缘和父控件的右边缘对齐
    android:layout_alignParentBottom="true"         –将控件的底边缘和父控件的底边缘对齐
    android:layout_centerInParent="true"               –将控件置于父控件的中心位置
    android:layout_centerHorizontal="true"            –将控件置于水平方向的中心位置
    android:layout_centerVertical="true"                –将控件置于垂直方向的中心位置

    参考:https://blog.csdn.net/afanyusong/article/details/44221595

  • 相关阅读:
    02.替换空格 (Java)
    01.二维数组中的查找 (Java)
    css
    CSS Selectors
    Golang Singleton
    TL;DR
    go get
    golang string、int、int64 float 互相转换
    Thrift支持的基本数据类型
    双亲委派模型
  • 原文地址:https://www.cnblogs.com/swjian/p/10188251.html
Copyright © 2020-2023  润新知