android灵活布局

一开始接触android,只知道拖拉布局,不灵活,难看很。后来才发现,原来和jsp一样,可以灵活使用xml文件。

话不多说,直接上例子

任何布局既可以在代码中实现,也可以在xml中实现。下面是用xml实现的一个例子

 

src文件中

layout目录下,新建test_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:stretchColumns="1"
        >
        <TableRow >
            <TextView
                android:text="ceshi"
                android:id="@+id/layoutTextView01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#ffff"
                >
               
            </TextView>
            <EditText
                android:text=""
                android:id="@+id/EditText01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
               
                />
           
        </TableRow>
        <TableRow android:gravity="right">
            <Button
                android:text="test"
                android:id="@+id/layoutButton1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                />
           
        </TableRow>
       
    </TableLayout>

</LinearLayout>


 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值