为了创建比例大小的子View,可以将LinearLayout的宽度和高度设为fill_parent, 而将子View的宽度或是高度设为0,然后为子View设置不同权重(weight) ,这样子View的大小就会权值成比例。

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"     >    <TextView        android:layout_width="0dp"        android:layout_height="match_parent"        android:layout_weight="1"        android:background="@color/orange" />    <TextView        android:layout_width="0dp"        android:layout_height="match_parent"        android:layout_weight="1"        android:background="@color/blue" />    <TextView        android:layout_width="0dp"        android:layout_height="match_parent"        android:layout_weight="1"        android:background="@color/coffee" />    <TextView        android:layout_width="0dp"        android:layout_height="match_parent"        android:layout_weight="1"        android:background="@color/yellow" /></LinearLayout>

效果图:



更多相关文章

  1. Android开发学习之View测量的内置常用方法
  2. Android(安卓)获取标题栏以及状态栏的高度
  3. android iphone手机分辨率尺寸比例整理
  4. Android根据屏幕宽度,按比例缩放图片
  5. Android标题栏渐变色,沉寂式状态栏
  6. [转]Android(安卓)获取当前Activity的屏幕截图
  7. Android中判断状态栏是否存在
  8. 高度状态栏Android获取状态栏的高度高度状态栏
  9. android中各种height和width总结

随机推荐

  1. Android应用开发之( TableLayout中stretch
  2. Android(安卓)8.0以上 竖屏到横屏 返回时
  3. Android(安卓)Espresso
  4. android 指定打包资源文件的方法
  5. Android输出log的包装
  6. Android(安卓)Weekly - 第 194 期
  7. 解决升级到Android(安卓)Studio 3 Beta版
  8. Android(java)学习笔记124:Android权限大全
  9. 以Android(安卓)Studio讲解Gradle在Andro
  10. Ubuntu下Android(安卓)Studio Gradle syn