Android的TextView的背景 [英] Android TextView Background
本文介绍了Android的TextView的背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一种设计,它需要像下面在右手侧的数字图像一个背景。有没有什么我们就可以在Android中实现这一目标?
i have a design which demands a background like the image below for the number on the right hand side. Is there any we can achieve this in Android ?
请问我需要一个9片图像,并将其设置为背景?
Will i need to make a 9 patch image and set it as a background ?
推荐答案
首先,创建一个形状有圆角。
First, create a shape to have rounded corners.
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF"/>
<corners android:radius="5px"/>
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
</shape>
然后将此作为背景,以你的观点:
Then apply this as the background to your Views:
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_edges">
<TextView
android:id="@+id/mytext"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:text="blah blah blah blah"
android:padding="6dip"
android:textColor="#000000" />
</LinearLayout>
您可能需要做一些调整。你甚至可以放弃的LinearLayout
,并设置安卓背景
的 TextView中的
到 @绘制/ rounded_edges
You may need to do some tweaking. You may even be able to discard the LinearLayout
and set the android:background
of the TextView
to @drawable/rounded_edges
这篇关于Android的TextView的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文