Domanda

Well basically I'm making an app which needs something like an action bar, 4 buttons bellow that and a listview on the rest of the screen. But I'm stuck at how to arrange them, since I'm also using a navigation drawer.

This is how it's supossed to look: lookalikeApp

The problem is that I have no idea how to arrange them properly I did this but I know it's wrong and it's still missing the actionbar like header:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<LinearLayout
    android:id="@+id/menu"
    android:layout_width="match_parent"
    android:layout_height="70dp"
    android:orientation="horizontal" >

        <ImageButton
            android:id="@+id/btnFormatos"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/b_formato"
            android:onClick="formatos"
            android:contentDescription="@string/desc"
             />

        <ImageButton
            android:id="@+id/btnTiendas"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/b_tiendas"
            android:onClick="tiendas"
            android:contentDescription="@string/desc"
             />
         <ImageButton
            android:id="@+id/btnMarcas"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/b_marcas"
            android:onClick="marcas"
            android:contentDescription="@string/desc"
             />

          <ImageButton
            android:id="@+id/btnGiros"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/b_categorias"
            android:onClick="categorias"
            android:contentDescription="@string/desc"
             />

          <ImageButton
            android:id="@+id/btnOrdenar"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/b_ordenar"
            android:onClick="ordenar"
            android:contentDescription="@string/desc"
             />
</LinearLayout>

<ListView
    android:id="@+id/list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:divider="#b5b5b5"
    android:dividerHeight="1dp"
    android:listSelector="@drawable/list_selector"
    android:translationY="70dp"
    android:layout_weight="1"
    />
<ListView
    android:id="@+id/left_drawer"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="#111"
    android:choiceMode="singleChoice"
    android:divider="@android:color/transparent"
    android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>

Not to mention that with translateY on my listView when I get to the bottom of the list I can't see the last item.

I know I'm supossed to be using fragments and I'm looking into that but that won't solve my initial problem so any help would be appreciated.

Thank you for your time

È stato utile?

Soluzione

Update your xml file as per code below

 <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/drawer_layout"
 android:layout_width="match_parent"
 android:layout_height="match_parent" >

      <FrameLayout android:layout_width="match_parent"
     android:layout_height="match_parent" >

           <LinearLayout
               android:id="@+id/menu"
               android:layout_width="match_parent"
               android:layout_height="70dp"
     android:orientation="horizontal" >

                <ImageButton
                    android:id="@+id/btnFormatos"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:src="@drawable/b_formato"
                    android:onClick="formatos"
                    android:contentDescription="@string/desc"
                     />

                <ImageButton
                    android:id="@+id/btnTiendas"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:src="@drawable/b_tiendas"
                    android:onClick="tiendas"
                    android:contentDescription="@string/desc"
                     />
                 <ImageButton
                    android:id="@+id/btnMarcas"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:src="@drawable/b_marcas"
                    android:onClick="marcas"
                    android:contentDescription="@string/desc"
                     />

                  <ImageButton
                    android:id="@+id/btnGiros"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:src="@drawable/b_categorias"
                    android:onClick="categorias"
                    android:contentDescription="@string/desc"
                     />

                  <ImageButton
                    android:id="@+id/btnOrdenar"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:src="@drawable/b_ordenar"
                    android:onClick="ordenar"
                    android:contentDescription="@string/desc"
                     />
           </LinearLayout>

           <ListView
               android:id="@+id/list"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:divider="#b5b5b5"
               android:dividerHeight="1dp" 
               android:listSelector="@drawable/list_selector"
               android:layout_marginTop="70dp"
               android:layout_weight="1"
               />

       </FrameLayout>


            <ListView
             android:id="@+id/left_drawer"
             android:layout_width="240dp"
             android:layout_height="match_parent"
             android:layout_gravity="start"
             android:background="#111"
             android:choiceMode="singleChoice"
             android:divider="@android:color/transparent"
             android:dividerHeight="0dp" />
 </android.support.v4.widget.DrawerLayout>

Try and enjoy.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top