2017-06-06 52 views
0

我是一名Android學習者,我試圖製作一個應用程序,將其顯示爲Toast.I在Android Studio上製作了應用程序,而且看起來沒問題,但是當我運行它時我的手機在Android 5.0上運行,所有的部件重疊,而在工作室中它看起來很好。請幫助。 這是它的外觀上的電話:小部件在Android應用中的活動中重疊

This is how it looks on Andro

這是它的外觀在Android

enter image description here

<?xml version="1.0" encoding="utf-8"?> 

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="com.example.rahulranjan.toast1.MainToast"> 



<Button 
    android:id="@+id/test1" 
    android:layout_width="368dp" 
    android:layout_height="wrap_content" 
    android:onClick="btnClick" 
    android:text="Click Me" 
    android:textColor="#00C957" 
    tools:layout_editor_absoluteY="130dp" 
    tools:layout_editor_absoluteX="8dp" /> 

<TextView 
    android:id="@+id/textView" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:text="Click Below to see Toast :" 
    tools:layout_editor_absoluteY="40dp" 
    tools:layout_editor_absoluteX="112dp" 
    android:textColor="#E3CF57" 
    /> 

而且是的,我已經使用ConstrainLayout,我不知道爲什麼它不在這裏顯示在這個網站上。 感謝

+1

刪除約束,並把相對佈局根 –

+0

感謝@AvinashRoy,改變其相對於佈局的工作,但你能告訴我是什麼的問題約束佈局? –

+0

請參閱頁面頂部橫幅中的鏈接問題。 [這個答案](https://stackoverflow.com/a/43422980)解釋得很好。 –

回答

0

編輯:

您使用約束佈局。你沒有給這些限制。添加約束這些,否則他們默認彈出到左上角:

<TextView 
android:id="@+id/textView" 
android:layout_width="0dp" 
android:layout_height="wrap_content" 
android:text="Click Below to see Toast :" 
tools:layout_editor_absoluteY="40dp" 
tools:layout_editor_absoluteX="112dp" 
android:textColor="#E3CF57" 
app:layout_constraintLeft_toRightOf="@id/test1" 
/> 
+0

我用過:

+0

對不起,我只是看到了。我編輯了我的評論以更好地解釋。希望有所幫助! –

相關問題