Android:如何设置TextView主题,使其看起来像ListView中的项目?

时间:2011-03-06 23:48:52

标签: android

我目前有一个位于ListView下方的TextView,并希望将TextView设为主题,使其看起来像列表中的项目(例如,带有顶部和底部灰色边框)。实现这一目标的最佳方法是什么?

1 个答案:

答案 0 :(得分:2)

创建一个可绘制的xml文件以创建具有渐变背景的形状。

textview_background.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<gradient
    android:startColor="#333"
    android:centerColor="#000"
    android:endColor="#676"
    android:angle="270"/>

<stroke
    android:width="2dp"
    android:color="#80808080"/>



</shape>

保存在drawable目录中并引用为

   android:background="@drawable/textview_background"

在您的布局中,了解您要使用的背景。文字视图,布局,按钮......

这应该会给你一些接近我想的东西。

渐变中使用的颜色是三重十六进制,我认为你可以使用正常的十六进制。

相关问题