zoukankan      html  css  js  c++  java
  • TableRow平均布局单元格(转载)

    android布局常常用到平均分配布局控件,比如用户登录的界面中登录与注册两个按钮,需要按1:1的比例平均分配到布局内容中,TableRow布局可以实现这样的效果。如图-1。需要设置android:layout_weight的权重。如果两个按钮均为android:layout_weight=”1″,则可以设置TableRow的比例为1:1,如果Login按钮设置android:layout_weight=”1″,Register按钮设置android:layout_weight=”2″,则Login按钮在TableRow布局中的比例为1:3,Register按钮在TableRow布局中的比例为2:3。

    xml文件如下:

    <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:padding=”12dip”>

    <TableRow android:layout_width=”fill_parent” android:layout_height=”wrap_content”> <Button android:layout_height=”fill_parent” android:layout_width=”fill_parent” android:text=”Login”  android:id=”@+id/loginBtn” android:layout_weight=”1″></Button> <Button android:layout_height=”fill_parent” android:layout_width=”fill_parent” android:text=”Register”  android:id=”@+id/registerBtn” android:layout_weight=”1″></Button> </TableRow>

    </LinearLayout>

     
     
     
     
     
  • 相关阅读:
    phpHttp请求头
    第八周学习总结
    梦断代码阅读笔记-03
    第七周学习总结
    针对自己开发项目的NABC的认知
    梦断代码阅读笔记
    第六周学习总结
    第五周学习总结
    移动端疫情展示
    第四周学习总结
  • 原文地址:https://www.cnblogs.com/merryjd/p/2794905.html
Copyright © 2011-2022 走看看