2017-10-08 3 views
1

In meiner App habe ich derzeit zwei Textansichten in einem Warndialog, um die Temperatur und die Wetterbeschreibung anzuzeigen. Das Problem dabei ist, dass sich die Ausrichtung ändert, wenn sich die Beschreibung ändert.Wie kann ich meinen Text korrekt im Android Studio zuweisen?

Ich habe versucht, mein Layout als ein relatives Layout und bewegen Sie beide mit einer abhängig von der anderen, aber das hilft mir nicht aus. Irgendwelche Vorschläge?

Dies ist mein aktueller Code:

<?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" 
    android:orientation="vertical"> 


    <TextView 
     android:id="@+id/climaText" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_alignStart="@+id/desc" 
     android:layout_marginTop="18dp" 
     android:layout_marginStart="120dp" 
     android:textColor="@android:color/white" /> 

    <TextView 
     android:id="@+id/desc" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/climaText" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="13dp" 
     android:textColor="@android:color/white" /> 



</RelativeLayout> 

Antwort

0

Es ist aufgrund geschieht in der Datengröße ändern, wenn die Daten erhöht werden, wird es die Daten wickelt, wenn Sie wrap_content verwenden. Ich schlage vor, Sie können eine Elternansicht verwenden und die Höhe korrigieren. Hier ist der Code, lassen Sie mich wissen, ob es funktioniert. danke

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="250px"> 

     <TextView 
      android:id="@+id/climaText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_alignStart="@+id/desc" 
      android:layout_marginStart="120dp" 
      android:layout_marginTop="18dp" 
      android:textColor="@android:color/white" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="250px"> 

     <TextView 
      android:id="@+id/desc" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/climaText" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="13dp" 
      android:textColor="@android:color/white" /> 

    </LinearLayout> 

</LinearLayout> 
+0

Sorry, das hat nicht funktioniert. –

Verwandte Themen