Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 向滑动导航添加具有自定义视图的片段_Android - Fatal编程技术网

Android 向滑动导航添加具有自定义视图的片段

Android 向滑动导航添加具有自定义视图的片段,android,Android,我想有一个导航抽屉,但里面有任意视图。不仅列出项目。可能吗?我应该使用哪个库来实现此功能?“可能吗?” 回答:是 “我应该使用哪个库来实现此功能?” 答:android sdk中的导航抽屉将完美工作。 官方文件: DrawerLayout类是ViewGroup的子类,这意味着它具有视图组的所有功能。我们不仅限于Listview,还可以在抽屉布局中添加任何类型的视图 例如: <?xml version="1.0" encoding="utf-8"?> <android.suppo

我想有一个导航抽屉,但里面有任意视图。不仅列出项目。可能吗?我应该使用哪个库来实现此功能?

“可能吗?”
回答:

“我应该使用哪个库来实现此功能?”

答:android sdk中的导航抽屉将完美工作。

官方文件:

DrawerLayout
类是
ViewGroup
的子类,这意味着它具有视图组的所有功能。我们不仅限于Listview,还可以在
抽屉布局
中添加任何类型的视图

例如:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<!-- The main content view -->
<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/holo_green_dark">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Content of drawer"
        android:textColor="@android:color/holo_red_dark"
        android:textSize="24sp"
        />

</FrameLayout>
<!-- The navigation drawer -->
<RelativeLayout
    android:id="@+id/left_drawer"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="#12D"
    >

    <TextView
        android:id="@+id/drawer_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="Custom view"
        android:textColor="@android:color/secondary_text_light"
        android:textSize="24sp"
        android:textStyle="bold"
        />

</RelativeLayout>

“可能吗?”
回答:

“我应该使用哪个库来实现此功能?”

答:android sdk中的导航抽屉将完美工作。

官方文件:

DrawerLayout
类是
ViewGroup
的子类,这意味着它具有视图组的所有功能。我们不仅限于Listview,还可以在
抽屉布局
中添加任何类型的视图

例如:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<!-- The main content view -->
<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/holo_green_dark">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Content of drawer"
        android:textColor="@android:color/holo_red_dark"
        android:textSize="24sp"
        />

</FrameLayout>
<!-- The navigation drawer -->
<RelativeLayout
    android:id="@+id/left_drawer"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="#12D"
    >

    <TextView
        android:id="@+id/drawer_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="Custom view"
        android:textColor="@android:color/secondary_text_light"
        android:textSize="24sp"
        android:textStyle="bold"
        />

</RelativeLayout>


检查此项,希望它能帮助您理解导航视图


检查此项,希望它能帮助您理解导航视图