Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.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_Navigation Drawer - Fatal编程技术网

Android 导航抽屉中的选项卡布局有问题

Android 导航抽屉中的选项卡布局有问题,android,navigation-drawer,Android,Navigation Drawer,我使用android。支持:导航抽屉和标签的设计库。 我有一个标签片段的问题,它的阴影和标签。 主要活动布局: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.and

我使用android。支持:导航抽屉和标签的设计库。 我有一个标签片段的问题,它的阴影和标签。

主要活动布局:

 <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout        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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:id="@+id/coordinate"
tools:context="tabs.com.tabs.com.fragments.items">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />


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


<include layout="@layout/content_main" />


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

如何解决此问题?

您可以尝试为TableAyout和ActionBar设置相同的提升值,因为工具栏提升了6dp,所以它将阴影投射到选项卡上。 将工具栏设置为TabLayout中的工具栏

对于使用AppCompatActivity的用户来说,这也很简单,只需将高程设置为

getSupportActionBar().setElevation(0)

==========================================================================================================

1) 另一种方法是,在XML设计中,您可以在选项卡下方绘制一个布局,其中包含可绘制的阴影部分

res/drawable/shadow.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
    android:startColor="@android:color/transparent"
    android:endColor="#33000000"
    android:angle="90">
</gradient>

现在把它当作

<View
    android:layout_width="match_parent"
    android:layout_height="8dp"
    android:layout_below="@id/TabLayoutID"
    android:background="@drawable/shadow" />

在包含TabLayout的主XML中

2)

或者在你的风格中添加这一行:如果上述方法不起作用

<item name="android:windowContentOverlay">@drawable/shadow</item>
@drawable/shadow

希望,我帮了你

您可以尝试为TabLayout和ActionBar设置相同的提升值,因为工具栏提升了6dp,所以它将阴影投射到选项卡上。 将工具栏设置为TabLayout中的工具栏

对于使用AppCompatActivity的用户来说,这也很简单,只需将高程设置为

getSupportActionBar().setElevation(0)

==========================================================================================================

1) 另一种方法是,在XML设计中,您可以在选项卡下方绘制一个布局,其中包含可绘制的阴影部分

res/drawable/shadow.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
    android:startColor="@android:color/transparent"
    android:endColor="#33000000"
    android:angle="90">
</gradient>

现在把它当作

<View
    android:layout_width="match_parent"
    android:layout_height="8dp"
    android:layout_below="@id/TabLayoutID"
    android:background="@drawable/shadow" />

在包含TabLayout的主XML中

2)

或者在你的风格中添加这一行:如果上述方法不起作用

<item name="android:windowContentOverlay">@drawable/shadow</item>
@drawable/shadow

希望,我帮了你

要移除
工具栏的阴影
请将其添加到应用程序主题中:

<item name="android:windowContentOverlay">@null</item>

要移除
工具栏的阴影
请将其添加到应用程序主题:

<item name="android:windowContentOverlay">@null</item>

AppBarOverlay
在工具栏上添加阴影。
AppBarOverlay
在工具栏上添加阴影。我向工具栏和选项卡添加了相同的高程,但阴影仍在此处。将两者的高程设置为0。。!当设置高程为0时,它将隐藏选项卡之间和选项卡下方的阴影,但我需要选项卡下方的阴影。我尝试只设置高程选项卡,但不起作用。很高兴我提供了帮助。!:)快乐编码。!我向工具栏和选项卡添加了相同的高程,但阴影仍在此处。将两个工具栏和选项卡的高程都设置为0。。!当设置高程为0时,它将隐藏选项卡之间和选项卡下方的阴影,但我需要选项卡下方的阴影。我尝试只设置高程选项卡,但不起作用。很高兴我提供了帮助。!:)快乐编码。!