0
您好我已经发现奇怪的行为,当试图在android上实现以下布局。视图高度计算不正确内加权布局
<?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="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.75"
android:orientation="horizontal" >
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="15dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:layout_margin="20dp"
android:textColor="@android:color/black"
android:lineSpacingMultiplier="1.1" />
</LinearLayout>
</LinearLayout>
这块布局应该在右侧生成一个占用75%屏幕的textview。但由于某种原因,Textview的高度计算就好像其父代的权重为0.视图内部的文本似乎完美包裹,但不是视图本身。
这是正常的行为,或者我如何让textview显示正确的高度?
我不希望它填满屏幕的高度,我使用wrap_content是有原因的。我已经尝试在TextView上设置权重无济于事。我也很清楚这种设置权重的方式,这是我个人的偏好。 –