0
我在爲片段中動態創建的自定義列表視圖的元素設置等寬空間時出現問題。所有元素都排列在同一個listview中。請給出一個想法,以便如何使它在自定義視圖中獨一無二。請參閱此圖像。幫我。提前致謝!!!!如何在Android中爲動態創建的自定義列表視圖設置相同的外觀?
代碼------>
<?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="match_parent" >
<TableRow>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp"
android:textSize="18sp"
android:textColor="#800080"
android:id="@+id/txt1">
</TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp"
android:textSize="18sp"
android:textColor="#800080"
android:id="@+id/txt2">
</TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp"
android:textSize="18sp"
android:textColor="#800080"
android:id="@+id/txt3">
</TextView>
<Button
android:id="@+id/del_button"
android:text="Delete"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:onClick="addItems"
android:layout_gravity="right"
android:theme="@style/MyButton"/>
</TableRow>
對不起。這不適合我..請給我一些其他的想法.. –
您可以使用TableRow.LayoutParams [這裏](https://developer.android.com/reference/android/widget/TableRow.LayoutParams.html) – MeLine
This權重增加了兩個listview之間的空間,但是我需要在單個listview的元素之間做出相等的空間。 –