简体   繁体   中英

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. 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 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM