小编Dam*_*ano的帖子

使用 TabLayout 添加片段时出现 Material Design 高程问题

我目前正在开发 v22 的应用程序并使用以下库:

compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:design:22.2.1'
Run Code Online (Sandbox Code Playgroud)

我只有一个名为HomeActivity 的活动,里面有一个导航抽屉。这是activity_home.xml布局:

<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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="false">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.ActionBar" />

    </android.support.design.widget.AppBarLayout>

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        />

</android.support.design.widget.CoordinatorLayout>

<android.support.design.widget.NavigationView
    android:id="@+id/navigation_view"
    android:layout_height="match_parent"
    android:layout_width="wrap_content"
    android:layout_gravity="start"
    app:menu="@menu/menu_navigation"/>
Run Code Online (Sandbox Code Playgroud)

因此,每次我从导航抽屉中选择一个项目时,我都会@+id/content_frame用一个新的 Fragment替换 FrameView ,如下所示:

int id = menuItem.getItemId();
            switch (id)
            {
                case R.id.gazzette:
                    fragmentManager.beginTransaction()
                            .replace(R.id.content_frame, new ListViewFragment())
                            .commit();
                    drawerLayout.closeDrawers();
                    break;
                case R.id.concorsi: …
Run Code Online (Sandbox Code Playgroud)

android fragment material-design android-elevation android-tablayout

5
推荐指数
1
解决办法
1009
查看次数