2017-12-03 5 views
1

Ich möchte den TextView Stick nach rechts oben setzen.TextView nicht auf der rechten Seite

Mein Code ist:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="Test.test.MainActivity"> 

    <FrameLayout 
     android:id="@+id/fragmentContainer" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="42dp"/> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="42dp" 
     android:layout_marginRight="0dp" 
     android:text="@string/Title1" 
     android:textSize="30dp" /> 

</android.support.constraint.ConstraintLayout> 

Ich versuche, die TextView einzustellen:

  • android:layout_alignParentRight="true"
  • android:layout_marginRight="0dp"
  • android:layout_marginTop="0dp"

Aber nichts funktioniert, die TextView bleiben in der linken oberen Ecke.

Jemand hat eine Idee für die Lösung?

UPDATE:

Wie links kleben TextView auf einen anderen TextView, die rechts Eltern haften?

ich versuche, den Wicht und nichts gesetzt ..

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_weight="0" 
    android:layout_height="42dp" 
    app:layout_constraintRight_toRightOf="parent" 
    android:text="@string/Title1" 
    android:textSize="30dp" /> 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="wrap_content" 
    android:layout_weight="1" 
    android:layout_height="42dp" 
    app:layout_constraintRight_toRightOf="parent" 
    android:text="@string/Title2" 
    android:textSize="30dp" /> 

I textView2 textView1 nach links werden wollen bleiben.

Suche Lösung zu aktualisieren ich in nur gesetzt textview2

  • App: layout_constraintBaseline_toBaselineOf = "@ + id/textView1"

  • App: layout_constraintEnd_toStartOf = "@ + id/textView1"

Danke,

Tal

Antwort

3

In Constraint-Layout, stellen Sie die richtige Einschränkung der TextView nach rechts von dem übergeordneten Layout es ausrichten

In folgenden Einschränkung zu Ihrem TextView

app:layout_constraintRight_toRightOf="parent" 

wie diese

nach rechts
<TextView 
     android:id="@+id/textViewHowMuchSigned" 
     android:layout_width="wrap_content" 
     android:layout_height="42dp" 
     app:layout_constraintRight_toRightOf="parent" 
     android:text="@string/Title" 
     android:textSize="30dp" /> 
+0

Vielen dank es funktioniert. – tal

Verwandte Themen