学android 首先学会怎么布局界面,我开始是学.net的,因工作需要学习一下安卓,外行写的不好,请多多见谅指教 。这一篇文章然我们来学习一下四种布局吧!
RelativeLayout(相对布局) 、LinearLayout(线性布局) 、TableLayout(表格布局)、FrameLayout(帧布局) 

1、RelativeLayout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="fill_parent"    android:layout_height="match_parent"    >    <TextView        android:id="@+id/lable"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="请输入" />    <EditText          android:id="@+id/txt"        android:layout_width="fill_parent"        android:layout_height="wrap_content"         android:background="@android:drawable/editbox_background"         android:layout_below="@id/lable"                />    <Button         android:id="@+id/OK"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@id/txt"        android:text="OK"        android:layout_alignParentRight="true"        android:layout_marginLeft="10px"        />         />    <Button         android:id="@+id/Cancel"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_toLeftOf="@id/OK"         android:layout_alignTop="@id/OK"        android:text="Cancel"              /></RelativeLayout>

2、LinearLayout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="fill_parent"    android:layout_height="fill_parent"     android:orientation="vertical"    >    <TextView        android:id="@+id/lable"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="请输入" />    <EditText          android:id="@+id/txt"        android:layout_width="fill_parent"        android:layout_height="wrap_content"         android:background="@android:drawable/editbox_background"         android:layout_below="@id/lable"                />    <Button         android:id="@+id/OK"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@id/txt"        android:text="OK"       android:layout_gravity="right"        />         />   </LinearLayout>

3、TableLayout

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"        android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:stretchColumns="1"    >   <TableRow >       <TextView            android:text="col1"           android:padding="3dip"           />        <TextView            android:text="col2"           android:padding="3dip"           android:gravity="right"           />          </TableRow>    <TableRow >       <TextView            android:text="col1"           android:padding="3dp"           />        <TextView            android:text="col2"           android:padding="3dp"           android:gravity="right"           />          </TableRow></TableLayout>

4、FrameLayout

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    >       <ImageView          android:layout_height="fill_parent"         android:layout_width="fill_parent"         android:src="@drawable/movie"                  />     <ImageView          android:layout_height="wrap_content"         android:layout_width="wrap_content"         android:src="@drawable/play"          android:layout_gravity="center"         /></FrameLayout>

更多相关文章

  1. Android(安卓)Flutter:Dart语言(布局篇)
  2. [Android]AndroidBucket增加碎片SubLayout功能及AISubLayout的注
  3. Android手机应用开发(三) | Intent、Bundle的使用以及RecyclerView
  4. Android———Layout:LinearLayout
  5. TextView 文本过长时自动打点
  6. Android使用SharedPreferences实现数据存储
  7. Android(安卓)Fragment学习笔记(二)
  8. 多种方式实现Android页面布局的切换
  9. Android(安卓)Studio 布局文件格式化代码

随机推荐

  1. Android(安卓)Hierarchy Viewer
  2. Android——自定义View类(一 )
  3. Android打开APP会有权限询问
  4. 使用新版Android(安卓)Studio检测内存泄
  5. Android(安卓)系统中的 WatchDog 详解
  6. Android文件操作总结
  7. 关于Qt和android ndk的兼容问题
  8. Android(安卓)Handler
  9. Android(安卓)避免内存泄露
  10. Android(安卓)利用getApplication() 共享