Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/179.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 文本视图,带背景和居中文本_Android_Background_Textview - Fatal编程技术网

Android 文本视图,带背景和居中文本

Android 文本视图,带背景和居中文本,android,background,textview,Android,Background,Textview,我想创建一个具有自定义背景的TextView。 特别是我想有一个文本视图,它看起来像。 我知道我可以使用android:background=“@drawable/displaybackground将背景设置为TextView,但如何在此TextView中对齐文本。文本应显示在TextView的中心,如上图所示 亲切问候找到以下链接: 祝你好运:)在文本视图(而不是布局_gravity)的重力属性中使用center。给你。 你只需要找到你喜欢的背景 <Textview andro

我想创建一个具有自定义背景的TextView。 特别是我想有一个文本视图,它看起来像。 我知道我可以使用android:background=“@drawable/displaybackground将背景设置为TextView,但如何在此TextView中对齐文本。文本应显示在TextView的中心,如上图所示


亲切问候

找到以下链接:


祝你好运:)

在文本视图(而不是
布局_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)
//背景(可绘制或彩色)

缺乏研究。这不是一个真正的问题。你找到答案了吗?