2010-10-14 117 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

相关问题