2013-06-29 1 views
0

Dans mon application ont six boutons, la taille de l'écran est 4.65 "720p (720X1280: xhdpi), appareil prend cette résolution du dossier de mise en page normale.quand je l'exécute sur device.it afficher comme l'image est montrée ci-dessous.Comment régler ces six boutons correspondent à l'écran en fonction de la largeur de mise en page et height.I ne sais pas solution.Can quelqu'un sait s'il vous plaît aidez-moi à résoudre ce problème.Support d'écran multiple dans Android?

XML Mon codage

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/home_xml" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#ffffff" > 

<Button 
    android:id="@+id/btn_login" 
    android:layout_width="101dp" 
    android:layout_height="193dp" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@+id/imageView1" 
    android:layout_marginLeft="4dp" 
    android:layout_marginTop="78dp" 
    android:background="@drawable/login_button" /> 

<Button 
    android:id="@+id/btn_order" 
    android:layout_width="101dp" 
    android:layout_height="wrap_content" 
    android:layout_alignBottom="@+id/btn_login" 
    android:layout_alignTop="@+id/btn_login" 
    android:layout_marginLeft="3dp" 
    android:layout_toRightOf="@+id/btn_login" 
    android:background="@drawable/order_button" /> 

<Button 
    android:id="@+id/btn_abtus" 
    android:layout_width="101dp" 
    android:layout_height="wrap_content" 
    android:layout_alignBottom="@+id/btn_order" 
    android:layout_alignTop="@+id/btn_order" 
    android:layout_marginLeft="3dp" 
    android:layout_toRightOf="@+id/btn_order" 
    android:background="@drawable/aboutus_button" /> 

<Button 
    android:id="@+id/btn_outlet" 
    android:layout_width="100dp" 
    android:layout_height="198dp" 
    android:layout_alignLeft="@+id/btn_login" 
    android:layout_alignRight="@+id/btn_login" 
    android:layout_below="@+id/btn_login" 
    android:background="@drawable/outlets_button" /> 

<Button 
    android:id="@+id/btn_feedback" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignBottom="@+id/btn_outlet" 
    android:layout_alignLeft="@+id/btn_order" 
    android:layout_alignRight="@+id/btn_order" 
    android:layout_alignTop="@+id/btn_outlet" 
    android:background="@drawable/feedback_button" /> 

<Button 
    android:id="@+id/btn_games" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignBottom="@+id/btn_feedback" 
    android:layout_alignLeft="@+id/btn_abtus" 
    android:layout_alignRight="@+id/btn_abtus" 
    android:layout_alignTop="@+id/btn_feedback" 
    android:background="@drawable/games_button" /> 

<RelativeLayout 
    android:id="@+id/relativeLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="44dp" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentTop="true" 
    android:background="#98110e" > 
</RelativeLayout> 

enter image description here

+0

http://stackoverflow.com/questions/17357682/how-can-i-made-the-layout-that-will-work-in-both-tablet-and-phone/17357736#17357736 – Nirmal

Répondre

2

Ici, vous allez:

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

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:orientation="horizontal" > 

    <Button 
     android:id="@+id/button3" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:text="Button" /> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:text="Button" /> 
</LinearLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:orientation="horizontal" > 

    <Button 
     android:id="@+id/button3" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:text="Button" /> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:text="Button" /> 
</LinearLayout> 

</LinearLayout> 

Layout_weight fait le bouton "partager" l'espace.

+0

Merci Stéphane Mathis. – Yugesh