Android的:如何主题一个TextView所以它看起来像在ListView的项目? [英] Android: How to theme a TextView so it looks like an item in a ListView?

查看:213
本文介绍了Android的:如何主题一个TextView所以它看起来像在ListView的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在有一个TextView坐在一个ListView下面,想主题的TextView,使它看起来像在列表中的项目(例如顶部和底部的灰色边框)。什么是实现这一目标的最佳方式?

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 bottom gray border). What's the best way to accomplish this?

推荐答案

创建绘制xml文件来创建一个形状渐变背景。

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

textview_background.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>

保存在绘制目录,并称之为

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.

这篇关于Android的:如何主题一个TextView所以它看起来像在ListView的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆