在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中的四种布局
  2. Android之TabLayout布局的使用
  3. Android Studio App设置线性布局LinerLayout控件垂直/水平方向排
  4. 【Android】Android中两种常用布局(LinearLayout和RelativeLayout
  5. Android之ListActivity:布局与数据绑定

随机推荐

  1. Android聊天软件开发(基于网易云IM即时通
  2. Android中使用菜单
  3. [Android]用AIDL生成Service
  4. 制作可独立分发的Android模拟器
  5. android资源提供介绍
  6. Android的安全与权限(1)
  7. android - ANR keyDispatchingTimedOut .
  8. android mk学习-添加lib包
  9. 简单分析android textview xml 的属性设
  10. android as gradle 使用过称中 错误处理