1

作成を手伝ってくださいToolbar。どのコンテンツが終了し@+id/left_drawerますか? 出来ますか? ここに画像の説明を入力

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar
        android:id="@+id/my_awesome_toolbar"
        style="@style/MainTheme.ToolBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <com.astuetz.RobottoRegularTextView
                android:id="@+id/toolbar_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:textColor="@android:color/white"
                android:textSize="20sp" />

            <com.astuetz.RobottoLightTextView
                android:id="@+id/toolbar_subtitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:textColor="@android:color/white"
                android:textSize="@dimen/small_text"
                android:visibility="gone" />
        </LinearLayout>
    </android.support.v7.widget.Toolbar>

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

<!--ImageView for test -->
<ImageView
    android:id="@+id/left_drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:layout_marginTop="0dp"
    android:layout_marginBottom="0dp"
    android:scaleType="centerCrop"
    android:adjustViewBounds="true"
    android:src="@drawable/background" />

4

3 に答える 3

1

親 LinearLayout 内では、Toolbar を最初に配置し、DrawerLayout を 2 番目に配置できます。

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <android.support.v7.widget.Toolbar
        android:id="@+id/my_awesome_toolbar"
        style="@style/MainTheme.ToolBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    (...)

    </android.support.v7.widget.Toolbar>

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <FrameLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <fragment
            android:id="@+id/left_drawer"
            android:layout_width="@dimen/navigation_drawer_width"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            tools:layout="@layout/fragment_navigation_drawer" />

    </android.support.v4.widget.DrawerLayout>

</LinearLayout>
于 2014-11-16T17:22:58.200 に答える
1

@hata は正解にかなり近かったです。UのToolbarDrawerLayoutに配置する必要があり、Toolbarの背景を透明にし、ツールバーのように高さが背景色になる前@+id/content_frameにフォームを作成します。ここにUの私の解決策がありますDrawerLayout?attr/actionBarSize

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.kpi.timetable.views.HackyDrawerLayout
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="@color/YOUR_ACTIONBAR_COLOR"/>

            <FrameLayout
                android:id="@+id/content_frame"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </LinearLayout>


        <ImageView
            android:id="@+id/left_drawer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:layout_marginBottom="0dp"
            android:layout_marginTop="0dp"
            android:adjustViewBounds="true"
            android:scaleType="centerCrop"
            android:src="@drawable/background" />
    </com.kpi.timetable.views.HackyDrawerLayout>

    <!-- in your MainTheme.ToolBar style set background       -->
    <!-- color to "@android:color/transparent" or set it here -->
    <!-- as android:background="@android:color/transparent"   -->
    <android.support.v7.widget.Toolbar
        android:id="@+id/my_awesome_toolbar"
        style="@style/MainTheme.ToolBar"            
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <com.astuetz.RobottoRegularTextView
                android:id="@+id/toolbar_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="Расписание"
                android:textColor="@android:color/white"
                android:textSize="20sp" />

            <com.astuetz.RobottoLightTextView
                android:id="@+id/toolbar_subtitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:textColor="@android:color/white"
                android:textSize="@dimen/small_text"
                android:visibility="gone" />
        </LinearLayout>
    </android.support.v7.widget.Toolbar>
</RelativeLayout>
于 2014-11-17T10:19:47.967 に答える
0

あなたが探しているのは、Navigation Drawer と呼ばれるものです。

Androidのドキュメントにアクセスすることをお勧めします

http://developer.android.com/training/implementing-navigation/nav-drawer.html

その場合、あなたのコードは

<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">

    <android.support.v7.widget.Toolbar
        android:id="@+id/my_awesome_toolbar"
        style="@style/MainTheme.ToolBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <com.astuetz.RobottoRegularTextView
                android:id="@+id/toolbar_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:textColor="@android:color/white"
                android:textSize="20sp" />

            <com.astuetz.RobottoLightTextView
                android:id="@+id/toolbar_subtitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:textColor="@android:color/white"
                android:textSize="@dimen/small_text"
                android:visibility="gone" />
        </LinearLayout>
    </android.support.v7.widget.Toolbar>

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <LinearLayout android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:background="#fff"/>
</android.support.v4.widget.DrawerLayout>
于 2014-11-16T16:26:17.530 に答える