现在的位置: 首页 > 移动开发 > 正文

Android学习笔记—09_深入了解各种布局技术

2019年09月19日 移动开发 ⁄ 共 2031字 ⁄ 字号 评论关闭

Android学习笔记---09_深入了解各种布局技术

09_深入了解各种布局技术
-------------------------------
1.Relativelayout相对布局
  padding:指的是内间距,大框套小框,指的是小框和大框之间的大小
  android:background="@android:drawable/..."android:指的是操作系统下的R文件
2.android:id="@+id/label"//在R文件中的内部类创建label,常量
  android:layout_below="@id/label"//少了一个加号,这里指的是在TextView这个控件的下 
  面,不需要添加到R文件中,所以不用写+号
----------------------------------------------
3.android:layout_alignParentRight="true"指的是要求该控件,对齐父窗体的右边
4.android:layout_marginleft="10px"代表控件的左边和控件左边的控件之间的间隙
5.android:layout_toleftor="@id/ok"代表该控件在ok控件的左边
6.android:layout_alignTop="@id/ok"指的是该控件要和ok控件的顶边对齐
-------------------------------------------------------------------
用相对布局,重新设计短信发送器的显示界面:
<RelativeLayout 
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
    >
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/number" 
        android:id="@+id/numberlabel"/>
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/number"
        android:layout_toRightOf="@id/numberlabel"
        android:layout_alignTop="@id/numberlabel"
        android:layout_marginLeft="5dp"
        />
    </RelativeLayout>
---------------------------------------------
2.表格布局:TableLayout
  a.android:stretchColumns="1"//是否可以拉伸
-------------------------------------------------------
3.帧布局:gif动画:FrameLayout
  <FrameLayout>
  <TextView.../>红色
  <TextView.../>绿色
</FrameLayout>
 和gif动画一样,绿色的一个控件,会叠加到红色的上面
 应用例子:一个视频播放器,背后的视频前有一个播放按钮
 a.把图片play.png,movie.png放到drawable-hdpi文件夹,
<?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>
------------------------

抱歉!评论已关闭.