Android 列在列表行上的分布不均匀
我正在显示带有自定义行的列表视图。有时文本较长,则行显示不正确。这意味着不同行的列(0,1)具有不同的宽度。我想将列的宽度固定为3:1,但似乎不起作用。下面是行布局的代码Android 列在列表行上的分布不均匀,android,Android,我正在显示带有自定义行的列表视图。有时文本较长,则行显示不正确。这意味着不同行的列(0,1)具有不同的宽度。我想将列的宽度固定为3:1,但似乎不起作用。下面是行布局的代码 <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical" >
<TextView
android:id="@+id/text_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Shoppers Stop"
android:textSize="25sp" />
<TextView
android:id="@+id/text_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="whitefield, bangalore"
android:textColor="#ffababab" />
<TextView
android:id="@+id/text_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="here is the subtitle" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<RatingBar
android:id="@+id/ratingbar"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:isIndicator="true"
android:numStars="5" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="enter" />
</LinearLayout>
</TableRow>
</TableLayout>
使用
布局重量时,应将相应的宽度/高度归零
例如,对两个加权的线性布局
元素使用layout\u width=“0dp”
-请参阅侧栏和示例代码。@Geobits好极了,请将其作为答案发布。