[英]Android TextView strange text alignment
In many different questions the answer to align the text inside a TextView was either: android:layout_width="match_parent"
or to set the gravity
or textAlignment
however none of these options seemed to work on my emulator. 在许多不同的问题中,使TextView内的文本对齐的答案是: android:layout_width="match_parent"
或设置gravity
或textAlignment
但是这些选项似乎都无法在我的模拟器上运行。 I don't have the preview since it's code generated text. 我没有预览,因为它是代码生成的文本。 Using my current layout I get this in my emulator: 使用当前的布局,我可以在仿真器中得到它: Why does the black text behave in such a strange way? 为什么黑色文本表现得如此奇怪? I want to left align it. 我想左对齐。 This is my current xml: 这是我当前的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>
I'm sorry to bother this comunity again with this question. 很抱歉再次困扰这个社区。
<TextView
android:text="Left Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|left"/>
Here's a similar question: Android TextView Align text to Right and Left 这是一个类似的问题: Android TextView将文本左右对齐
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.