2016-09-05 59 views
0

這就是我想要的:android.support.v7.widget.Toolbar不是棉花糖設備工作正常

enter image description here

這就是我得到:

enter image description here

這個問題帶有api 23.在22或21上,它給出了第一個圖像所示的結果。

我的build.gradle是:

apply plugin: 'com.android.application' 


android { 
compileSdkVersion 22 
buildToolsVersion '22.0.1' 

defaultConfig { 
    applicationId "com.example.bob" 
    minSdkVersion 15 
    targetSdkVersion 22 
    versionCode 3 
    versionName "1.0.1" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
    } 
} 
} 
repositories { 
mavenCentral() 
} 
dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
compile 'com.android.support:appcompat-v7:22.2.0' 
compile 'com.facebook.android:facebook-android-sdk:4.0.0' 
compile files('libs/android-query-full.0.26.7.jar') 
compile files('libs/android-async-http-1.4.4.jar') 
compile 'com.google.android.gms:play-services-gcm:7.8.0' 
compile 'com.google.android.gms:play-services-ads:7.8.0' 
compile 'com.android.support:support-v4:22.2.0' 
compile 'com.github.bumptech.glide:glide:3.7.0' 
compile 'com.squareup.picasso:picasso:2.5.2' 
compile 'com.android.support:design:22.2.0' 
compile'com.github.wrdlbrnft:sorted-list-adapter:0.1.0.5' 
compile ('jp.wasabeef:recyclerview-animators:2.2.3'){ 
    exclude module: 'appcompat-v7' 
} 
} 

而且我的Android佈局文件是:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout  
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" 
tools:context=".SongList"> 

<android.support.design.widget.AppBarLayout 
    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"/> 
    <!-- 
     app:layout_scrollFlags="scroll|enterAlways"/> 
     --> 

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

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

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

而且Toolbar集的Java文件:

setContentView(R.layout.activity_songlist); 

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    setSupportActionBar(toolbar); 

我不想升級編譯和目標版本bcz然後我將不得不爲每一個添加運行時權限方法清單中指定的權限。

+0

你在'song_list'佈局中添加了佈局行爲? –

+0

是的...我已經添加了像這樣的應用程序:layout_behavior =「@ string/appbar_scrolling_view_behavior」@Uttam Panchasara –

+1

此代碼可以正常使用棒棒糖和更低版本。該問題只出現在棉花糖裝置中。 –

回答

0

嘗試在AppBarLayout加入這一行:

android:fitsSystemWindows="true" 

而且從CoordinatorLayout刪除它。

相關問題