问大家一个小问题在如下例子中。。要用到layout_weight 这个属性值。则他的LinearLayout 的layout_width 必须设置成 fill_parent 设置成 wrap_content可以吗?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/a1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:layout_weight="1"
/>
<TextView
android:id="@+id/a2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:layout_weight="2"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/a1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:layout_weight="1"
/>
<TextView
android:id="@+id/a2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:layout_weight="2"
/>
</LinearLayout>
解决方案 »
- 关于 android 应用中多个activity的问题
- android mediaplay的循环播放问题 播第二遍只播放一一小段就结束了?
- main.xml要调用layout下的另一个文件line.xml应该如何写?
- android通话界面的问题??急急急急
- 如何修改RadioGroup 或 radiobuttom的样式?在线求助
- eclipse 不认识Android api了 有图
- 关于用intent调用自身activity
- 怎么用android studio测试工程
- 手头有一份MTK的 android 8.0源码,如果升级升级到8.1 求方法
- 请问,安卓系统在开发3D应用和游戏方面用什么引擎做开发?
- 请假:怎么获知用户是否使用积分去除广告?
- Android程序如何启动UC浏览器或者Android自带浏览器
官方文档中描述如下:
Tip: To create a proportionate size layout on the screen, create a container view group object with the layout_width and layout_height attributes set to fill_parent; assign the children height or width to 0 (zero); then assign relative weight values to each child, depending on what proportion of the screen each should have.