你好傢伙我試圖改變我的導航抽屜項目的高度,我不知道如何,我已經到處尋找,盡我所能,但似乎沒有任何工作..如何自定義導航抽屜項目高度
這是定製有有圖像下的文本,但我也想那個形象要大些我的抽屜式導航欄項目。
結果我仰視的是:
隨着高度的周圍75dp爲每一個項目,也是我希望菜單上的寬度短,得到的圖像在外觀。
我使用的是自定義佈局我當然項目,我命名爲:menu_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_margin="10dp">
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:src="@drawable/menu_icon"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Menu Title"
android:textSize="16sp"
android:textColor="@color/white" />
</LinearLayout>
我activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/colorPrimaryDark"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
最後的菜單; activity_main_drawer.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/nav_profile"
app:actionLayout="@layout/menu_item"/>
</menu>
任何想法如何實現我想要什麼?在此先感謝
編輯:當我在我的自定義項目放大圖片如下:
這是menu_item.xml
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:src="@drawable/menu_icon"/>
..我得到這樣的結果:
正如你看到我的形象比項目更大..
你可以自定義導航佈局 –
要實現這一點,只需創建一個自定義佈局。 – RameshJaga
@Anas你試過我的答案嗎? – Moulesh