情景一, 布局文件代码如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/linearLayout1"    android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:orientation="horizontal" >    <TextView        android:id="@+id/textView1"        android:layout_width="wrap_content"        android:layout_height="fill_parent"        android:layout_weight="1"        android:text="TextView1" />    <TextView        android:id="@+id/textView2"        android:layout_width="wrap_content"        android:layout_height="fill_parent"        android:layout_weight="9"        android:text="TextView2" /></LinearLayout>

parent view中 android:layout_width="fill_parent" 两个child view:

TextView1 android:layout_weight="1"

TextView2 android:layout_weight="9"

宽度比例效果图如下:

android 布局文件 layout_weight用法_第1张图片

结论:当linearLayoutandroid:layout_width="fill_parent"viewandroid:layout_weigh表示权重比例几分之几的概念,此条件下:TextView1宽度为整个宽度的1/10;


linearLayoutandroid:layout_width="wrap_content"viewandroid:layout_weigh表示权重比例不起作用没有效果

   

更多相关文章

  1. android LinearLayout android:layout_weight 作用,固定比例
  2. android线性布局之比例
  3. android 骁龙相机预览宽度方向全屏
  4. Android imageView图片按比例缩放
  5. Android TextView使用权重时文字无法居中问题
  6. 权重
  7. 关于android LinearLayout的比例布局
  8. 【android】两个按钮的宽度各占屏幕的一半
  9. Android新增AppCompatTextView自适应字体大小和文本宽度

随机推荐

  1. Python_学习之项目日志管理
  2. CI/CD笔记-Gitlab-ci/cd部署实践
  3. Docker_学习笔记系列之docker-stack
  4. 首门程序员理财课 Python量化交易系统实
  5. Docker_学习笔记系列之docker-swarm
  6. [face_算法篇]:常见的二分、递归、选择、
  7. CI/CD笔记-Jenkins与gitlab实现CICD
  8. Prometheus 之 Grafana连接监控数据源与
  9. Docker_学习笔记系列之docker-compose
  10. CI/CD笔记-Jenkins的基本管理