如何创建自定义导航抽屉?
How to create custom navigation drawer?
我想创建 custom navigation drawer
,但我在 navigation
中有按钮和 EditText
。我用它来 filter.but 我不能这样创建。
实现自定义相当容易
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--here is your navigation drawer just create what layout you want inside it-->
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent">
<!--here you can create your custom view like this-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
之后您可以简单地定义我们为其他视图所做的 ID,并在它们上设置 onclicklistener
以获得点击事件
我想创建 custom navigation drawer
,但我在 navigation
中有按钮和 EditText
。我用它来 filter.but 我不能这样创建。
实现自定义相当容易
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--here is your navigation drawer just create what layout you want inside it-->
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent">
<!--here you can create your custom view like this-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
之后您可以简单地定义我们为其他视图所做的 ID,并在它们上设置 onclicklistener
以获得点击事件