2013-10-05 8 views
0

J'essaie d'obtenir l'interface utilisateur suivante: une page d'accueil avec des images statiques et du texte.Créer un menu basé sur GridLayout Android

enter image description here

je suis venu avec TableLayout mais il n'a pas été totalement flexible dans le cas où le changement de mise en page. Puis gridlayout est venu, mais il est encore impossible de se moquer exactement la même chose que la capture d'écran.

Alors, ma question est de savoir quelle disposition convient le mieux? PS: Les images ne sont pas de la même taille et cohérentes les unes avec les autres.

+0

qui pourrait être fait assez facilement avec la disposition relative. – FoamyGuy

+0

Le problème est que ces images sont assez grandes. J'ai besoin de les redimensionner en réponse avec toutes les tailles d'écran –

Répondre

1
// try this 
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:weightSum="2" 
       android:orientation="vertical"> 
    <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:orientation="vertical"> 

     <LinearLayout 
       android:id="@+id/linearlayout1" 
       android:layout_width="match_parent" 
       android:layout_weight="1" 
       android:layout_height="0dp" 
       android:orientation="vertical" > 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 
      <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:adjustViewBounds="true" 
        android:scaleType="fitXY" 
        android:src="@drawable/ic_launcher"/> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" 
       android:padding="5dp" 
       android:background="@android:color/transparent" 
       android:text="Special"/> 
      </RelativeLayout> 
     </LinearLayout> 

     <LinearLayout 
       android:id="@+id/linearlayout1" 
       android:layout_width="match_parent" 
       android:layout_weight="1" 
       android:layout_height="0dp" 
       android:orientation="vertical" > 

      <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="match_parent"> 
       <ImageView 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:adjustViewBounds="true" 
         android:scaleType="fitXY" 
         android:src="@drawable/ic_launcher"/> 
       <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentBottom="true" 
         android:padding="5dp" 
         android:background="@android:color/transparent" 
         android:text="Dishes"/> 
      </RelativeLayout> 
     </LinearLayout> 
    </LinearLayout> 
    <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:orientation="vertical"> 

     <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1" 
       android:weightSum="2"> 
      <LinearLayout 
        android:id="@+id/linearlayout1" 
        android:layout_width="0dp" 
        android:layout_weight="1" 
        android:layout_height="match_parent" 
        android:orientation="vertical" > 

       <RelativeLayout 
         android:layout_width="match_parent" 
         android:layout_height="match_parent"> 
        <ImageView 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 
          android:adjustViewBounds="true" 
          android:scaleType="fitXY" 
          android:src="@drawable/ic_launcher"/> 
        <TextView 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_alignParentBottom="true" 
          android:padding="5dp" 
          android:background="@android:color/transparent" 
          android:text="Event"/> 
       </RelativeLayout> 
      </LinearLayout> 

      <LinearLayout 
        android:id="@+id/linearlayout1" 
        android:layout_width="0dp" 
        android:layout_weight="1" 
        android:layout_height="match_parent" 
        android:orientation="vertical" > 

       <RelativeLayout 
         android:layout_width="match_parent" 
         android:layout_height="match_parent"> 
        <ImageView 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 
          android:adjustViewBounds="true" 
          android:scaleType="fitXY" 
          android:src="@drawable/ic_launcher"/> 
        <TextView 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_alignParentBottom="true" 
          android:padding="5dp" 
          android:background="@android:color/transparent" 
          android:text="Location"/> 
       </RelativeLayout> 
      </LinearLayout> 
     </LinearLayout> 
    </LinearLayout> 
</LinearLayout> 
0

essayer cette

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

    <LinearLayout 
     android:id="@+id/linearlayout1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 

     <ImageView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/linearlayout2" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/linearlayout1" 
     android:orientation="vertical" > 

     <ImageView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/linearlayout2" 
     android:orientation="horizontal" 
     android:weightSum="2" > 

     <ImageView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 

     <ImageView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 
    </LinearLayout> 


</RelativeLayout> 
+0

J'ai suivi votre mise en page mais il finit comme ça https://dl.dropboxusercontent.com/u/10120454/captures/ScreenCapture%20at%20Sat%20Oct%205%2013%3A04 % 3A19% 20EST% 202013.png –

+1

mise en page alinment est mssing j'ai changé la structure de mise en page essayez maintenant – venu

+0

Oui, j'ai reconnu le manque de positionnement dans votre mise en page et l'a changé mais il est encore vissé. Le problème principal est que ces images ne sont pas de la même taille et assez grandes. https://dl.dropboxusercontent.com/u/10120454/captures/ScreenCapture%20at%20Sat%20Oct%205%2013%3A46%3A57%20EST%202013.png –

Questions connexes