[英]Android TextView strange text alignment
在许多不同的问题中,使TextView内的文本对齐的答案是: android:layout_width="match_parent"
或设置gravity
或textAlignment
但是这些选项似乎都无法在我的模拟器上运行。 我没有预览,因为它是代码生成的文本。 使用当前的布局,我可以在仿真器中得到它: 为什么黑色文本表现得如此奇怪? 我想左对齐。 这是我当前的xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:font="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
tools:context="com.domain.citytour.activity.ImpressumActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/locationTitle"
android:textAlignment="center"
android:padding="@dimen/activity_horizontal_margin"
android:background="@color/primary"
android:textColor="@color/cardview_light_background"
android:textSize="20sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:textAlignment="viewStart"
android:id="@+id/locationContent"
android:padding="@dimen/activity_horizontal_margin"
android:textColor="@color/primary_text"
android:textSize="14sp"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
很抱歉再次困扰这个社区。
<TextView
android:text="Left Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|left"/>
这是一个类似的问题: Android TextView将文本左右对齐
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.