Android 在小型线性布局中对齐文本视图中心
这似乎是一个微不足道的问题,但我发现在小版面中对齐TextView是一件痛苦的事情。 以下是xml: 背景图像是一个9patch,因此有填充,但文本未居中,被截断。我会发布一个输出图像,但显然这被认为是垃圾邮件。我尝试了很多东西,但这种情况仍然存在。较小的文本确实可以改善图像的居中,但只有非常小的文本才能正确居中。知道为什么吗?试试这个Android 在小型线性布局中对齐文本视图中心,android,android-layout,Android,Android Layout,这似乎是一个微不足道的问题,但我发现在小版面中对齐TextView是一件痛苦的事情。 以下是xml: 背景图像是一个9patch,因此有填充,但文本未居中,被截断。我会发布一个输出图像,但显然这被认为是垃圾邮件。我尝试了很多东西,但这种情况仍然存在。较小的文本确实可以改善图像的居中,但只有非常小的文本才能正确居中。知道为什么吗?试试这个 <LinearLayout android:layout_width="match_parent"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/button_bg_phone">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:shadowColor="#88FFFFFF"
android:shadowDx="0"
android:shadowDy="1"
android:shadowRadius="0.2"
android:textColor="#6d5013"
android:textSize="24sp" />
scaleType不是TextView的属性。我确实尝试将layoutHeight=matchParent放入,但问题仍然存在。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/button_bg_phone">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:shadowColor="#88FFFFFF"
android:shadowDx="0"
android:shadowDy="1"
android:shadowRadius="0.2"
android:textColor="#6d5013"
android:textSize="24sp" />