Android 各种布局技术-五大布局对象
16lz
2021-01-23
android:layout_width只能设置fill_parent(横向填充整个屏幕)或wrap_content(横向填充控件本身大小)
android:width设置具体控件的横向大小单位是像素
FrameLayout, LinearLayout , AbsoluteLayout, RelativeLayout, TableLayout.
----- FrameLayout-----
Demo1:
activity_main.xml
ok
<FrameLayout 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" > <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="100dp" android:inputType="textPassword" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello_world" tools:context=".MainActivity" /> <Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="@string/hello" android:textColor="#0000ff" android:textColorHighlight="#aaaaaa" android:textSize="20dp" android:textStyle="bold" tools:context=".MainActivity" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/world" android:textColor="#333333" android:textStyle="italic" tools:context=".MainActivity" /></FrameLayout>
res/values/目录下的xml文件中设置@string对应的value
----------
??
<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" ><ImageView android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/movie" /><ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/play" android:layout_gravity="center" /></FrameLayout>
movie 和 play 是res/drawable目录下对应的图片文件名
----- LinearLayout(线性布局)-----
----
-----AbsoluteLayout(绝对布局)----
----
----
----
----RelativeLayout(相对布局) -----
----
----
----
----- TableLayout(表格布局) -----
----
----
----
----
----
更多相关文章
- Android学习笔记06:线性布局LinearLayout
- 界面布局
- android基础入门控件详解(3)
- Android 布局中 如何使控件居中
- 系出名门Android(7) - 控件(View)
- Android中的布局管理
- 相对布局控制控件居右显示
- android布局实例代码