###前提・実現したいこと
CoordinatorLayoutを使用して上下のスワイプ操作で
Toolbarが隠れたり出たりするレイアウトを作成したところ、
下端(上端)までスクロールした際に出る丸いアニメーションが表示されません。
正確には、途中から下端(上端)まで一気にスワイプして、下端(上端)に達した瞬間は
表示されるんですが、すでに下端(上端)まで達してる状態からさらに下端(上端)にスワイプ
した際に丸いアニメーションが表示されません。
どうやったら常に下端(上端)までスクロールした際に丸いアニメーションが出るようにできますでしょうか。
###発生している問題・エラーメッセージ
エラーメッセージはなし
###該当のソースコード
build.gradleのdependencies部分(support:designを追加)
gradle
1dependencies { 2 compile fileTree(dir: 'libs', include: ['*.jar']) 3 androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 4 exclude group: 'com.android.support', module: 'support-annotations' 5 }) 6 compile 'com.android.support:appcompat-v7:24.2.1' 7 testCompile 'junit:junit:4.12' 8 9 compile "com.android.support:design:24.2.1" 10}
style.xml(Toolbarを使う為、NoActionBarに変更)
xml
1<resources> 2 3 <!-- Base application theme. --> 4 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 5 <!-- Customize your theme here. --> 6 <item name="colorPrimary">@color/colorPrimary</item> 7 <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 8 <item name="colorAccent">@color/colorAccent</item> 9 </style> 10 11</resources>
activity_main.xml
xml
1<?xml version="1.0" encoding="utf-8"?> 2<android.support.design.widget.CoordinatorLayout 3 xmlns:android="http://schemas.android.com/apk/res/android" 4 xmlns:app="http://schemas.android.com/apk/res-auto" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" > 7 8 <android.support.design.widget.AppBarLayout 9 android:id="@+id/app_bar" 10 android:layout_width="match_parent" 11 android:layout_height="wrap_content" 12 android:fitsSystemWindows="true" > 13 14 <android.support.v7.widget.Toolbar 15 android:id="@+id/toolbar" 16 android:layout_width="match_parent" 17 android:layout_height="?attr/actionBarSize" 18 app:layout_scrollFlags="scroll|enterAlways" /> 19 20 </android.support.design.widget.AppBarLayout> 21 22 <android.support.v4.widget.NestedScrollView 23 app:layout_behavior="@string/appbar_scrolling_view_behavior" 24 android:layout_width="match_parent" 25 android:layout_height="match_parent"> 26 27 <LinearLayout 28 android:orientation="vertical" 29 android:layout_width="match_parent" 30 android:layout_height="wrap_content"> 31 32 <View android:background="#ffff0000" android:layout_width="match_parent" android:layout_height="200dp" /> 33 <View android:background="#ff00ff00" android:layout_width="match_parent" android:layout_height="200dp" /> 34 <View android:background="#ff0000ff" android:layout_width="match_parent" android:layout_height="200dp" /> 35 <View android:background="#ffffff00" android:layout_width="match_parent" android:layout_height="200dp" /> 36 <View android:background="#ffff00ff" android:layout_width="match_parent" android:layout_height="200dp" /> 37 <View android:background="#ff00ffff" android:layout_width="match_parent" android:layout_height="200dp" /> 38 39 </LinearLayout> 40 41 </android.support.v4.widget.NestedScrollView> 42 43</android.support.design.widget.CoordinatorLayout>
MainActivity.java(プロジェクト作成後そのまま)
java
1import android.support.v7.app.AppCompatActivity; 2import android.os.Bundle; 3 4public class MainActivity extends AppCompatActivity { 5 6 @Override 7 protected void onCreate(Bundle savedInstanceState) { 8 super.onCreate(savedInstanceState); 9 setContentView(R.layout.activity_main); 10 } 11}
###試したこと
Toolbarの
app:layout_scrollFlags="scroll|enterAlways"
を消して、Toolbarを上下のスワイプで隠さないようにすると、
下端(上端)までスクロールした状態からさらにスクロールした際も丸いアニメーションが出る
###補足情報(言語/FW/ツール等のバージョンなど)
java
Android studio 2.2.2
あなたの回答
tips
プレビュー