2016-08-30 100 views
1

工具欄上移工具欄上移

http://i.stack.imgur.com/QCXYs.png

如何使一個正常的嗎?

如何製作透明工具欄?我用抽屜由Mike朋茲和標籤 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> 
+0

可能是你使用全屏幕主題:像下面

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()創建方法。 –

+0

@АндрейУжегов如果您使用我的抽屜爲什麼您的佈局中定義了'DrawerLayout'? – mikepenz

回答

0

這是因爲你設置android:fitsSystemWindows="true"

android:fitsSystemWindows屬性根據系統窗口(如狀態欄)調整視圖佈局。如果爲true,則調整此視圖的填充以爲系統窗口留出空間。只有當此視圖處於非嵌入式活動時纔會生效。

要麼你可以刪除此行或將其設置爲

+0

沒有工作,窗口爲false –

+0

你有沒有對systemWindow進行任何編程? –

1

你能做到的兩種方式。

首先由xml:您可以爲不同的API級別設置不同的維度並在您的AppBar中設置填充。

其次在Java:

set this padding on your Appbar. 
+0

沒有工作,.... –