2017-07-02 44 views
0

Androidスタジオを使い始めたばかりで、ボタンとテキストフィールドを挿入しました。プレビューパネルでは大丈夫ですが、アプリを実行するとレイアウトが異なります。 これはXMLコードです:Androidスタジオエミュレータの別のレイアウト

<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:paddingBottom="16dp" 
android:paddingTop="16dp" 
android:paddingLeft="16dp" 
android:paddingRight="16dp" 

tools:context="com.example.alexander.myapplication.MainActivity"> 


<TextView 
    android:id="@+id/message" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="TextView" 
    tools:ignore="HardcodedText" /> 

<Button 
    android:id="@+id/button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Button" 
    tools:layout_editor_absoluteX="119dp" 
    tools:layout_editor_absoluteY="222dp" 
    tools:ignore="HardcodedText,MissingConstraints" 
    android:onClick="buttonClicked" 
    /> 

This is how it looks like ありがとうございました!ラインで

答えて

0

ルック:

tools:layout_editor_absoluteX="119dp" 
tools:layout_editor_absoluteY="222dp" 

彼らの言うことは、あなたが絶対位置ではなく、唯一のエディタプレビューのボタンを置いていることです。 アプリケーションが実際に実行されているときに、ボタンに実際のプレースメント値がありません(パラメータ名に「editor」プレフィックスが付いています)。

エディタで実際の値を定義する必要があります。

は、Android開発者サイトで、このガイドをチェックアウト: Build a Responsive UI with ConstraintLayout

0

私はRelativeLayoutにレイアウトを設定することで問題を解決しました。

関連する問題