2014-05-12 3 views
0

Je suis en train de faire une mise en page en bas comme dans l'image 1.Obtenir la mise en page déformée de la mise en page en bas

correct image

Mais lorsque les travaux d'application, la mise en page en bas obtient étirées sur grand écran comme dans l'image 2: incorrect image

est ici la source ...

<RelativeLayout 
    android:id="@+id/bottom_layout" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@layout/footer_color" 
    android:layout_alignParentBottom="true"> 
<LinearLayout 
    android:id="@+id/bottom_layout1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:weightSum="1.0" 
    android:orientation="horizontal"> 

<Button 
    android:id="@+id/bottom_layout11" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_weight="0.2" 
    android:gravity="center" 
    android:background="@drawable/profile_01"/> 
<Button 
    android:id="@+id/bottom_layout12" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:layout_weight="0.2" 
    android:background="@drawable/profile_01"/> 
<Button 
    android:id="@+id/bottom_layout13" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_weight="0.2" 
    android:gravity="center" 
    android:background="@drawable/profile_01"/> 
<Button 
    android:id="@+id/bottom_layout14" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_weight="0.2" 
    android:gravity="center" 
    android:background="@drawable/profile_01"/> 
    <Button 
    android:id="@+id/bottom_layout15" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_weight="0.2" 
    android:gravity="center" 
    android:background="@drawable/profile_01"/> 

    </LinearLayout> 
    </RelativeLayout> 

mise en page de bas de page nécessaire- w espace égal sur toute résolution sans étirement. Je ne comprends pas où je devrais améliorer le code. Répondez, s'il vous plaît .

Merci d'avance.

+0

pourquoi vous hardcoding la hauteur de mise en page par rapport à 50dp..let il être wrap_content et juste utilisez les images de la bonne taille .. – Vikram

+0

donnant le même résultat @Vikram –

+0

voir la mise à jour 1 ... –

Répondre

1
// try this way,hope this will help you... 

Note : please put respective images on all size drawable folder. 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/bottom_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@layout/footer_color" 
    android:layout_alignParentBottom="true"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center"> 
      <Button 
       android:id="@+id/bottom_layout11" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/profile_01"/> 
     </LinearLayout> 
     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center"> 
      <Button 
       android:id="@+id/bottom_layout12" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/profile_01"/> 
     </LinearLayout> 
     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center"> 
      <Button 
       android:id="@+id/bottom_layout13" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/profile_01"/> 
     </LinearLayout> 
     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center"> 
      <Button 
       android:id="@+id/bottom_layout14" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/profile_01"/> 
     </LinearLayout> 
     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center"> 
      <Button 
       android:id="@+id/bottom_layout15" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/profile_01"/> 
     </LinearLayout> 
    </LinearLayout> 
</RelativeLayout> 
+0

Merci mon pote @Haresh –

1

Si vous souhaitez prendre en charge différents écrans, vous devez fournir des images et des valeurs en fonction des écrans.

Créez values et drawable pour chaque taille d'écran. Spécifiez votre taille et la largeur dans le dossier de valeurs si vous souhaitez utiliser la coutume autrement le faire comme match_parent et wrap_content.

Vous devez créer quatre dossiers

values-ldpi // Small Screens 
values-mdpi // Medium Screens 
values-hdpi // Large Screens 
values-xhdpi // Xtra Large Screens 

Aussi, vous devez utiliser des tailles d'image correcte. Pour les tailles s'il vous plaît vérifier Android Support Mulitple Screens

+0

je sais cela, mais je ce qu'il faut faire comme donné en question (méthode différente ... mmm je suppose) ... –

1

essayer ce code:

<RelativeLayout 
    android:id="@+id/bottom_layout" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@layout/footer_color" 
    android:layout_alignParentBottom="true"> 
<LinearLayout 
    android:id="@+id/bottom_layout1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:weightSum="1.0" 
    android:orientation="horizontal"> 
    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:weightSum="0.2" 
     > 
    <Button 
     android:id="@+id/bottom_layout11" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:background="@drawable/profile_01"/> 
    </LinearLayout> 
    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:weightSum="0.2" 
     > 
    <Button 
     android:id="@+id/bottom_layout12" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:background="@drawable/profile_01"/> 
    </LinearLayout> 
    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:weightSum="0.2" 
     > 
    <Button 
     android:id="@+id/bottom_layout13" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:background="@drawable/profile_01"/> 
    </LinearLayout> 
    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:weightSum="0.2" 
     > 
    <Button 
     android:id="@+id/bottom_layout14" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:background="@drawable/profile_01"/> 
    </LinearLayout> 
    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:weightSum="0.2" 
     > 
     <Button 
     android:id="@+id/bottom_layout15" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:background="@drawable/profile_01"/> 
     </LinearLayout> 
     </LinearLayout> 
     </RelativeLayout> 

partagent la sortie ..

Questions connexes