android开发分享Android开发 UI组件

布局管理器线性布局(linearLayout)常用属性:android:idandroid:layout_widthandroid:layout_heightandroid:background //自定义背景颜色 图片android:layout_margin //外边距,距离外部元素的边距android:layout_padding //内边距android:orintation //线性布局的方向<?xml version=”1.0″ enco…


布局管理器

线性布局(linearLayout)

常用属性:

android:id  

android:layout_width

android:layout_height

android:background //自定义背景颜色 图片

android:layout_margin  //外边距,距离外部元素的边距

android:layout_padding  //内边距

android:orintation  //线性布局的方向

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="https://schemas.android.com/apk/res/android"     xmlns:app="https://schemas.android.com/apk/res-auto"     xmlns:tools="https://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical"     tools:context=".MainActivity">      <LinearLayout         android:id="@+id/ll_1"         android:layout_width="200dp"         android:layout_height="200dp"         android:background="#000000"         android:orientation="vertical"         android:paddingLeft="20dp"         android:paddingTop="20dp"         android:paddingRight="20dp"         android:paddingBottom="20dp"         android:layout_marginTop="20dp"         android:layout_marginLeft="15dp">          <View             android:layout_width="match_parent"             android:layout_height="match_parent"             android:background="#FF0033" />      </LinearLayout>      <LinearLayout         android:layout_width="match_parent"         android:layout_height="200dp"         android:orientation="horizontal"         android:background="#0066FF"         android:layout_marginLeft="15dp"         android:layout_marginRight="15dp"         android:layout_marginTop="15dp">          <View             android:layout_width="0dp"             android:layout_height="match_parent"             android:background="#FF0005"             android:layout_weight="1"/>          <View             android:layout_width="0dp"             android:layout_height="match_parent"             android:background="#000000"             android:layout_weight="1"/>      </LinearLayout>  </LinearLayout>

Android开发 UI组件

 

相对布局(RelativeLayout)

常用属性

android:layout_toLeftOf  //在谁左边

android:layout_toRightOf //在谁右边

android:layout_alignBottom  //在谁底部对齐

android:layout_alignParentBottom   //跟父控件底部对齐

anddroid:layout_below  //在谁下面

<RelativeLayout xmlns:android="https://schemas.android.com/apk/res/android"     xmlns:app="https://schemas.android.com/apk/res-auto"     xmlns:tools="https://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent">      <View         android:id="@+id/view_1"         android:layout_width="100dp"         android:layout_height="100dp"         android:background="#000000" />      <View         android:id="@+id/view_4"         android:layout_width="100dp"         android:layout_height="100dp"         android:background="#FF0033"         android:layout_toRightOf="@id/view_1"/>      <LinearLayout         android:id="@+id/view_4_1"         android:layout_width="match_parent"         android:layout_height="200dp"         android:layout_below="@id/view_1"         android:orientation="horizontal"         android:background="#0066FF"         android:padding="15dp">             <View                 android:layout_width="100dp"                 android:layout_height="match_parent"                 android:background="#ff0033"/>             <RelativeLayout                 android:layout_width="match_parent"                 android:layout_height="match_parent"                 android:background="#000000"                 android:padding="15dp">                 <View                     android:id="@+id/yellow"                     android:layout_width="100dp"                     android:layout_height="match_parent"                     android:background="#FF9900" />                 <View                     android:layout_width="100dp"                     android:layout_height="match_parent"                     android:layout_toRightOf="@id/yellow"                     android:background="#0033FF"                     android:layout_marginLeft="15dp"/>             </RelativeLayout>      </LinearLayout>      <View         android:id="@+id/view_2"         android:layout_width="100dp"         android:layout_height="100dp"         android:background="#000000"         android:layout_alignParentBottom="true" />      <View         android:id="@+id/view_3"         android:layout_width="100dp"         android:layout_height="100dp"         android:background="#000000"         android:layout_alignParentBottom="true"         android:layout_alignParentRight="true"/>  </RelativeLayout>

Android开发 UI组件

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/addevelopment/892809.html

(0)
上一篇 2021年10月20日
下一篇 2021年10月20日

精彩推荐