2016-10-20 2 views
0

In vielen verschiedenen Fragen war die Antwort, um den Text in einem TextView auszurichten, entweder: android:layout_width="match_parent" oder um die gravity oder textAlignment einzustellen, aber keine dieser Optionen schien auf meinem Emulator zu funktionieren. Ich habe keine Vorschau, da es sich um Code handelt, der durch Text generiert wurde. Mit meinem aktuellen Layout bekomme ich das in meinem Emulator: enter image description here Warum verhält sich der schwarze Text so seltsam? Ich möchte es ausrichten. Dies ist mein derzeitiges xml:Android TextView seltsame Textausrichtung

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

Es tut mir leid, diese Community erneut mit dieser Frage zu belästigen.

+1

Ich vermute, es hat etwas mit Ihrem „Code generiert Text“ zu tun. – tachyonflux

+1

Ich stimme zu, denn ich habe Ihren Code in einem Mini-Projekt ohne jede Änderung getestet und der Text wurde linksbündig – Michael

+0

Ich habe diese Antwort erwartet: -/ –

Antwort

0
<TextView 
     android:text="Left Text" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="start|left"/> 

Hier ist eine ähnliche Frage: Android TextView Align text to Right and Left

+0

Nichts geändert, sah diese Frage bereits :( –

+0

'android: gravity = "Left", benutze stattdessen diesen. – Michael

+0

Nein, nichts neues –