Android--入门---12---(android 布局的学习)

参见:API | Developer | Common LayoutObjects

较好的学习和参考方法:参见API 中的 simple

设置背景:为图形(图形:图片 + 颜色 + 动画 + 状态列表)

xxx.xml :android:background="图形"

padding :内间距(单位:px)

@android:drawable/editbox_background  :引用android系统的 R 文件 常量资源

相对布局:RelativeLayout

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

android:id=“@+id/button"  :表示向 R  文件中添加一个ID

android:layout_below="@id/button" :表示此控件放置于 引用为ID 的控件的地下

android:layout_toLeftof=“@id/button”  :表示此控件放置于 应用为ID 的控件的左边

android:layout_toRightOf="@id/button":表示此控件放置于 应用为ID 的控件的右边
android:layout_alignTop="@id/textview" <!--与指定ID的控件顶部对齐-->
android:layout_marginLeft="5dp" <!--控件左边间距为5像素-->

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

表格布局:tableLayout

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"   <!--xmlns : xml namespace-->
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:stretchColumns="1">
    <TableRow>      <!---当中的一个控件就是一列-->
        <TextView
            android:text="@string/table_layout_4_open"
            android:padding="3dip" />
        <TextView
            android:text="@string/table_layout_4_open_shortcut"
            android:gravity="right"
            android:padding="3dip" />
    </TableRow>

    <TableRow>     <!---当中的一个控件就是一列-->
        <TextView
            android:text="@string/table_layout_4_save"
            android:padding="3dip" />
        <TextView
            android:text="@string/table_layout_4_save_shortcut"
            android:gravity="right"
            android:padding="3dip" />
    </TableRow>
</TableLayout>

          

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

帧布局 : FrameLayout (与 gif 动画类似)

资源文件:

1.desktop.jpg

2.hand.jpg


----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


<?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/desktop"/>
        
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:src="@drawable/hand"/>
</FrameLayout>

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

效果图:





此外还有:absoluteLayout在此处不做介绍!





























 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值