开发者

Android: How to theme a TextView so it looks like an item in a ListView?

I currently have a TextView sitting below a ListView and would like to theme the TextView so that it looks like an item in the list (e.g. with top and bott开发者_如何学编程om gray border). What's the best way to accomplish this?


Create a drawable xml file to create a shape with a gradient background.

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>

save in your drawable directory and refer to as

   android:background="@drawable/textview_background"

in your layout for a background of what you want to use. Text view, layout, button...

This should give you something close to what your looking for I think.

The colors used in the gradient are triple hex, i think you can use normal hex.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜