2014-02-06 21 views

回答

1

您可以創建RelativeLayout(或另一個ViewGroup)並在其中插入ImageView以及TextView。將RelativeLayout的背景設置爲黑色。將TextView的文本顏色設置爲白色。然後,爲整個RelativeLayout設置一個View.OnClickListener

+0

我試圖做到這一點但我不能。你能寫出示例代碼嗎? – user3170606

+0

這是我無法看到你的進步所能提供的。請編輯你原來的帖子,以你到目前爲止的嘗試。另外,試試Tobor的答案 - 它更有效率。 – BVB

3

這是可能的。並且通過使用單個TextView而沒有任何其他控件。
請注意,您可以像使用Button一樣使用TextView。

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="#f000" 
    android:drawableTop="@drawable/your_picture" 
    android:drawablePadding="4dp" 
    android:padding="4dp" 
    android:gravity="center" 
    android:textSize="16sp" 
    android:textStyle="bold" 
    android:textColor="#ffff" 
    android:text="TEXT" 
/>