Android 文本视图,带背景和居中文本
我想创建一个具有自定义背景的TextView。 特别是我想有一个文本视图,它看起来像。 我知道我可以使用android:background=“@drawable/displaybackground将背景设置为TextView,但如何在此TextView中对齐文本。文本应显示在TextView的中心,如上图所示Android 文本视图,带背景和居中文本,android,background,textview,Android,Background,Textview,我想创建一个具有自定义背景的TextView。 特别是我想有一个文本视图,它看起来像。 我知道我可以使用android:background=“@drawable/displaybackground将背景设置为TextView,但如何在此TextView中对齐文本。文本应显示在TextView的中心,如上图所示 亲切问候找到以下链接: 祝你好运:)在文本视图(而不是布局_gravity)的重力属性中使用center。给你。 你只需要找到你喜欢的背景 <Textview andro
亲切问候找到以下链接:
祝你好运:)在文本视图(而不是
布局_gravity
)的重力属性中使用center
。给你。
你只需要找到你喜欢的背景
<Textview
android:layout_width="200dp"
android:layout_height="200dp"
android:gravity="center_vertical|center_horizontal" //center the text horizontally, and vertically
android:text="You place your text here..." // Text inside the TextView
android:background="background Here"/> // Background (drawable or color)
//背景(可绘制或彩色)
缺乏研究。这不是一个真正的问题。你找到答案了吗?