Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/315.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
Java 工具栏向上移动_Java_Android - Fatal编程技术网

Java 工具栏向上移动

Java 工具栏向上移动,java,android,Java,Android,工具栏向上移动 如何做一个正常人 以及如何使工具栏透明?我用mike penz的抽屉和tabs activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.androi

工具栏向上移动

如何做一个正常人

以及如何使工具栏透明?我用mike penz的抽屉和tabs activity_main.xml

<?xml version="1.0" encoding="utf-8"?>


<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_activity_DrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">

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

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

    <su.gamepoint.opendomofon.pro.sliding.SlidingTabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:elevation="2dp"
        android:background="@color/ColorPrimary" />

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:layout_weight="1">
    </android.support.v4.view.ViewPager>

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


这是因为您设置了
android:fitsystemwindows=“true”

android:fitsSystemWindows属性可根据系统窗口(如状态栏)调整视图布局。如果为true,则调整此视图的填充以为系统窗口留出空间。仅当此视图位于非嵌入式活动中时才会生效


您可以删除这一行,或者将其设置为false。您可以通过两种方式来完成

首先通过
xml
:您可以为不同的API级别设置不同的维度,并在
AppBar
中设置填充

其次,通过java:创建一个如下所示的方法

 public int getStatusBarHeight() {
    int result = 0;
    int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        result = getResources().getDimensionPixelSize(resourceId);
    }
    return result;
}
然后在您的
onCreate()
中:


可能您使用全屏主题。@Ажжжжжжжжж如果您使用我的抽屉,为什么您的布局中定义了
抽屉布局
?您是否编程给出了有关systemWindow的任何信息?
   set this padding on your Appbar.