使用layout_weight使控件按比例填满父控件

来源:互联网 发布:赵薇事件 知乎 编辑:程序博客网 时间:2024/06/10 06:54
<appfordaisy.controls.JTextView
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:text="确定"
   android:id="@+id/pic_ok"
   android:textSize="20dp"
   android:layout_weight="1"></appfordaisy.controls.JTextView>
<appfordaisy.controls.JTextView
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:text="取消"
   android:id="@+id/pic_cancel"
   android:textSize="20dp"

   android:layout_weight="1"></appfordaisy.controls.JTextView>


当兄弟控件都设置为match_parent时,可用weight来权衡他们的比重,若A的weight为x,B的weight为y,则A占x/(x+y)的比例空间,B同理。

原创粉丝点击