2017-04-11 7 views
2

Ich versuche, ein Layout mit android.support.constraint.ConstraintLayout, von Android-Studio zu entwerfen Ich kann sehen, die Vorschau ist gut, aber wenn ich gebaut und im Telefon laufen zeigt die Vorschau nacheinander, dass ich niemals wollen.tools: layout_editor_absoluteY funktioniert nicht

mein Layout-Design: enter image description here

<?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" 
    android:background="@color/black" 
    tools:context="co.gakkmedia.videoapps.DetailsViewActivity"> 


    <ImageView 
     android:id="@+id/videoView" 
     android:layout_width="wrap_content" 
     android:layout_height="200dp" 
     tools:layout_editor_absoluteY="0dp" 
     tools:layout_editor_absoluteX="0dp" 
     android:src="@drawable/video_preview_01" 
     /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Arraw" 
     android:textSize="20dp" 
     tools:layout_editor_absoluteY="166dp" 
     tools:layout_editor_absoluteX="0dp" 

     android:textColor="@color/white" 

     /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="09.45.05" 
     tools:layout_editor_absoluteY="166dp" 
     tools:layout_editor_absoluteX="291dp" 

     android:textSize="20dp" 
     android:textColor="@color/white" 
     /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="2016" 
     tools:layout_editor_absoluteY="200dp" 
     tools:layout_editor_absoluteX="0dp" 

     android:textSize="20dp" 
     android:textColor="@color/white" 
     /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="5 sections" 
     tools:layout_editor_absoluteY="200dp" 
     tools:layout_editor_absoluteX="101dp" 

     android:textSize="20dp" 
     android:textColor="@color/white" 
     /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Add to MyPlaylist" 
     tools:layout_editor_absoluteY="243dp" 
     tools:layout_editor_absoluteX="112dp" 

     android:textSize="20dp" 
     android:textColor="@color/white" 
     /> 

</android.support.constraint.ConstraintLayout> 

Antwort

5

Die layout_editor Attribute sind nur für die Editor-Vorschau und haben keine Auswirkung auf den endgültigen Layouts verwendet. Sie sollten Ihre Elemente mit den spezifischen Attributen ConstraintLayout positionieren.

+0

Als was Nutzen von ConstraintLayout ist. – Tariqul

+2

Es gibt viele Vorteile, aber Sie verwenden nicht die 'ConstraintLayout'-Funktionen, Sie positionieren nur die Ansichten absolut und es funktioniert nicht, da diese absoluten Positionierungswerte nur für die Editor-Vorschau funktionieren. Zum Beispiel sollten Sie 'app: layout_constraintTop_toBottomOf =" @ id/videoView "' auf dem Jahr 'TextView' verwenden, wenn es immer unter der _videoView_' ImageView' positioniert werden soll –

Verwandte Themen