2017-07-07 32 views
0

間距對AppBarLayout和惹尼運動虛擬移動不完整的應用程序欄標題間距對AppBarLayout

是我所有的手機問題確定

問題截圖:

problem screenshot

在虛擬手機上截屏:

on virtual mobile ok

activity_main.xml中

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 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/activity_main" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 
<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="56dp" 
     android:background="?attr/colorPrimary" 
     app:layout_scrollFlags="scroll|enterAlways" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

    <android.support.design.widget.TabLayout 
     android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     app:tabMode="fixed" 
     android:layoutDirection="rtl" 
     app:tabGravity="fill" 
     android:layout_height="wrap_content" /> 
</android.support.design.widget.AppBarLayout> 

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

</LinearLayout> 

回答

0

嘗試改變的主要活動(在導致問題)在清單的風格,應該這樣做。使用「基本活動」模板創建新項目時,可以檢查默認值。

在這種情況下,由於您的佈局包含一個工具欄,您應該使用默認主題(或自定義效果):android:theme="@style/AppTheme.NoActionBar"。請注意,我正在使用模板的默認值。你所需要的風格應該是這樣的:

<style name="AppTheme.NoActionBar"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
</style> 

這將是明顯的條目:

<activity 
    android:name=".MainActivity" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme.NoActionBar"> 
    <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 

     <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
</activity> 

BTW,以防萬一你還沒有做它,可以考慮在所有相同的API水平測試設備(虛擬和物理)來獲得一致的測試結果。

希望它有幫助!