2017-03-16 141 views
-5

我有一個包含三個按鈕的相對佈局的簡單應用程序,但它在模擬器中啓動時會一直崩潰。我的應用程序不斷崩潰

我的佈局XML是波紋管顯示:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <Button 
     android:id="@+id/one" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true"></Button> 

    <Button 
     android:id="@+id/two" 
     android:layout_alignParentTop="true" 
     android:layout_toRightOf="@id/one"></Button> 

    <Button 
     android:id="@+id/three" 
     android:layout_alignParentTop="true" 
     android:layout_toRightOf="@id/two"></Button> 
</RelativeLayout> 
+5

除非你貼您的崩潰消息,我們將無法幫助您 –

+3

請添加您的logcat,並在emu中檢查您的清單 – Jehad

+0

lator它說「appname不停地停止」 – userr

回答

0

設置寬度,高度,按鈕

 <?xml version="1.0" encoding="utf-8"?> 
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <Button 
      android:id="@+id/one" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true"/> 

     <Button 
      android:id="@+id/two" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_toRightOf="@id/one" /> 

     <Button 
      android:id="@+id/three" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_toRightOf="@id/two" /> 
    </RelativeLayout> 
+0

非常感謝它的工作 – userr

+0

不客氣:)請接受回答 – user2025187

0

添加的android:layout_width和android:layout_height的按鈕