diff --git a/docs-android/app/src/main/AndroidManifest.xml b/docs-android/app/src/main/AndroidManifest.xml index b56057b5..66708a1d 100644 --- a/docs-android/app/src/main/AndroidManifest.xml +++ b/docs-android/app/src/main/AndroidManifest.xml @@ -28,6 +28,7 @@ android:name=".activity.MainActivity" android:label="@string/app_name" android:launchMode="singleTop" + android:theme="@style/AppTheme.NoActionBar" android:windowSoftInputMode="adjustNothing"> @@ -43,6 +44,9 @@ + + + { + private int toolbarHeight; + + public ScrollingFABBehavior(Context context, AttributeSet attrs) { + super(context, attrs); + this.toolbarHeight = getToolbarHeight(context); + } + + @Override + public boolean layoutDependsOn(@NonNull CoordinatorLayout parent, @NonNull FloatingActionButton fab, @NonNull View dependency) { + return dependency instanceof AppBarLayout; + } + + @Override + public boolean onDependentViewChanged(@NonNull CoordinatorLayout parent, @NonNull FloatingActionButton fab, @NonNull View dependency) { + if (dependency instanceof AppBarLayout) { + CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); + int fabBottomMargin = lp.bottomMargin; + int distanceToScroll = fab.getHeight() + fabBottomMargin; + float ratio = dependency.getY() /(float) toolbarHeight; + fab.setTranslationY(- distanceToScroll * ratio); + } + return true; + } + + private int getToolbarHeight(Context context) { + final TypedArray styledAttributes = context.getTheme().obtainStyledAttributes( + new int[] { R.attr.actionBarSize }); + int toolbarHeight = (int) styledAttributes.getDimension(0, 0); + styledAttributes.recycle(); + + return toolbarHeight; + } +} \ No newline at end of file diff --git a/docs-android/app/src/main/res/layout/doc_list_fragment.xml b/docs-android/app/src/main/res/layout/doc_list_fragment.xml index ff83398e..979a1672 100644 --- a/docs-android/app/src/main/res/layout/doc_list_fragment.xml +++ b/docs-android/app/src/main/res/layout/doc_list_fragment.xml @@ -1,6 +1,5 @@ @@ -37,17 +36,4 @@ android:textSize="16sp" android:layout_centerInParent="true"/> - - \ No newline at end of file diff --git a/docs-android/app/src/main/res/layout/main_activity.xml b/docs-android/app/src/main/res/layout/main_activity.xml index cc9d2fdc..e5375a54 100644 --- a/docs-android/app/src/main/res/layout/main_activity.xml +++ b/docs-android/app/src/main/res/layout/main_activity.xml @@ -6,11 +6,47 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + android:layout_height="match_parent"> + + + + + + + + + + + + + @color/colorAccent + +