2014-07-06 4 views
1

J'ai une vue de liste et un bouton dans ma disposition relative.Bouton non affiché dans l'émulateur

Il est affiché dans la vue graphique Eclipse. Mais dans Emulator Listview seulement montrer. Bouton non affiché dans l'émulateur.

Mon code XML ici

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


<ListView 
    android:id="@+id/listView1" 
    android:layout_width="match_parent" 
    android:layout_height="415dp" > 
</ListView> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/listView1" 
    android:layout_centerHorizontal="true" 
    android:onClick="submit" 
    android:text="SUBMIT" /> 

</RelativeLayout> 

Mon code manifeste

<uses-sdk 
android:minSdkVersion="14" 
android:targetSdkVersion="19" /> 


<activity android:name="com.androidexample.tabbar.Tab1" 
android:theme="@android:style/Theme.DeviceDefault.NoActionBar"> 
</activity> 

Merci pour votre aide ..

Répondre

1

J'efface mon ancien code et crée une nouvelle mise en page relative maintenant fonctionne maintenant bien.

Cause de l'erreur est Je convertis manuellement la disposition linéaire en mise en page relative.

mon code après modification est:

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

<ListView 
    android:id="@+id/listView1" 
    android:layout_width="match_parent" 
    android:layout_height="420dp" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" > 
</ListView> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="14dp" 
    android:text="Button" 
    android:onClick="submit"/> 

</RelativeLayout> 
1

Utilisez les éléments suivants:

<ListView 
    android:id="@+id/listView1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:[email protected]"+id/button1" > 
</ListView> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_alignParentBottom="true" 
    android:onClick="submit" 
    android:text="SUBMIT" />