在android的布局中,有时为了适配不同的分辨率的机型,可以使用android:layout_weight这个属性。layout_weight表示所在的权重,即所描述的控件所在的百分比。

例如:

<LinearLayout

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_weight="1.0"

android:orientation="vertical">

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_weight="1.0"

android:Text="text"/>

<ImageView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_weight="2.0"/>

</LinearLayout>

在上述LinearLayout布局中,layout被分成3份,TextView占其中1份(即1/3),ImageView占2份(即2/3)。

平时做一些UI布局时,可以根据实际情况使用layout_weight。

更多相关文章

  1. 【Android】Android中两种常用布局(LinearLayout和RelativeLayout
  2. Android(安卓)自定义带百分比的进度条
  3. Android点击EditText以外区域隐藏键盘Fragment同样适用
  4. Android(安卓)EditText加入图片混编显示
  5. Android全局变量
  6. Android(安卓)Layout_weight 属性
  7. Android(安卓)SDK升级至revision 12后的一个Bug及解决方案
  8. android 颜色、 透明度参考表
  9. android singleTask几个注意点

随机推荐

  1. Android(安卓)Configuration系统设置
  2. Android(安卓)危险权限、权限组列表和所
  3. JitPack - 发布Android库
  4. Android(安卓)Studio 新建项目的R文件丢
  5. Android约束布局ConstraintLayout动态设
  6. 【Android(安卓)开发入门】android studi
  7. Fragment 的两种创建方式
  8. Android入门之四大组件
  9. android开发之四种基本布局和自定义控件
  10. 在 Android(安卓)studio 中 配置Gradle