2010-10-14 95 views

回答

1
<TextView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="72dp" 
    android:layout_height="wrap_content" 
    android:text="@string/label" 
    android:drawableTop="@drawable/icon" 
/> 

像這樣的東西應該工作。使用drawableTop/Left/Right屬性將允許您將圖像放置在標籤上方。完整的屬性列表可以在here找到。

你可以嘗試的另一件事是:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="72dp" 
    android:layout_height="wrap_content" 
    > 
    <TextView 
     android:text="@string/label" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/background_shape" 
     android:id="@+id/text" 
     /> 
    <ImageView 
     android:src="@drawable/icon" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:scaleType="fitCenter" 
     android:layout_above="@id/text" 
     /> 
</RelativeLayout> 
+0

不錯,做工精細。但是有什麼辦法可以獲得相同的文字背景嗎? (灰色,圓角) – Coxer 2010-10-14 14:23:15

+0

我現在無法測試它,但是您可以使用可繪製圓角的形狀,並執行'android:background =「@ drawable/background」'。不過,我不確定這是否僅包含文本,或者也包括上面提到的圖像。 – kcoppock 2010-10-14 14:36:09

+0

我已經測試過,它也包含圖片 – Coxer 2010-10-14 14:56:34

相關問題