[英]Android arranging layouts
好吧,基本上,我正在制作一個需要諸如操作欄,下面有4個按鈕以及屏幕其余部分上的列表視圖之類的應用。 但是我仍然在如何安排它們,因為我還使用了導航抽屜。
看起來像這樣:
問題是我不知道如何正確地排列它們,但是我知道這是錯誤的,並且仍然缺少標題欄等動作欄:
<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>
更不用說當我到達列表底部時,在listView上使用translateY時,我看不到最后一項。
我知道應該使用片段,但我正在調查,但這不能解決我的最初問題,因此,我們將不勝感激。
感謝您的時間
按照下面的代碼更新您的xml文件
<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>
嘗試並享受。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.