2017-07-26 45 views
-2

我是Android Studio的新手,所以我需要一點幫助。我正在研究2.3.3。所以預覽與實際模擬器上的視圖不匹配。請幫忙。Android Studio Preview不一樣

預覽圖像

enter image description here

模擬器映像

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="#006699" 
    tools:context="a.myapplication.MainActivity"> 

    <TextView 
     android:id="@+id/textView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="My App" 
     android:textColor="#ffffff" 
     android:textSize="85px" 
     tools:ignore="MissingConstraints" 
     tools:layout_editor_absoluteX="100dp" 
     tools:layout_editor_absoluteY="264dp" /> 
</android.support.constraint.ConstraintLayout> 
+1

https://stackoverflow.com/questions/42594033/constraintlayout-views-in-top-left-corner – CommonsWare

回答

0

刪除工具:從XML屬性爲預覽的唯一作品

<TextView 
 
     android:id="@+id/textView" 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:text="My App" 
 
     android:textColor="#ffffff" 
 
     android:textSize="85px" 
 
     app:layout_constraintStart_toStartOf="parent" 
 
     app:layout_constraintEnd_toEndOf="parent" 
 
     app:layout_constraintTop_toTopOf="parent" 
 
     app:layout_constraintBottom_toBottomOf="parent" 
 
     />

This is good article for constraint layout

相關問題