我正在使用使用內聯刪除按鈕的自定義ListView
,但當ListView
行超過1行時無法讓按鈕垂直拉伸。在ListView中垂直拉伸按鈕
我也有一些問題,讓文本尊重按鈕的邊界,雖然這是工作更早,所以我懷疑這是一個簡單的修復。
我使用的代碼如下:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/txt_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="center_vertical"
android:textStyle="bold"
android:textSize="22sp"
android:textColor="#000000"
android:textIsSelectable="false"
android:layout_margin="8dp" />
<Button
android:id="@+id/btn_delete"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:background="@drawable/delete"
android:contentDescription="@string/delete"/>
</RelativeLayout>
它找出來,像這樣:
什麼'@繪製/ delete'?它看起來像一個圖像(帶有X的紅色矩形),不是嗎? – 2013-02-28 13:37:29
是的,這是一個9patch drawable,我將按鈕的背景設置爲 – 2013-02-28 13:38:59
請分享9patch。 – 2013-02-28 13:50:51