Skip to content

Commit

Permalink
tweaked flexible space UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Suleiman19 committed Mar 11, 2017
1 parent dcbb6c4 commit 692eec3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion MaterialSample/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions MaterialSample/app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class AnimateToolbar extends AppCompatActivity {
private Menu collapsedMenu;
private boolean appBarExpanded = true;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -60,7 +59,6 @@ public void onGenerated(Palette palette) {
});

recyclerView = (RecyclerView) findViewById(R.id.scrollableview);

// Use when your list size is constant for better performance
recyclerView.setHasFixedSize(true);

Expand All @@ -76,22 +74,20 @@ public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
Log.d(AnimateToolbar.class.getSimpleName(), "onOffsetChanged: verticalOffset: " + verticalOffset);

// Vertical offset == 0 indicates appBar is fully expanded.
if (Math.abs(verticalOffset) > 120) {
if (Math.abs(verticalOffset) > 200) {
appBarExpanded = false;
invalidateOptionsMenu();
} else {
appBarExpanded = true;
invalidateOptionsMenu();
}

}
});

}

@Override
public boolean onPrepareOptionsMenu(Menu menu) {

if (collapsedMenu != null
&& (!appBarExpanded || collapsedMenu.size() != 1)) {
//collapsed
Expand All @@ -100,10 +96,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
} else {
//expanded


}

return super.onPrepareOptionsMenu(collapsedMenu);
}

Expand All @@ -123,7 +116,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.action_settings:
return true;
}

if (item.getTitle() == "Add") {
Toast.makeText(this, "clicked add", Toast.LENGTH_SHORT).show();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.CoordinatorLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="192dp"
android:layout_height="@dimen/appbar_header_height"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

Expand All @@ -32,7 +34,7 @@

<View
android:layout_width="match_parent"
android:layout_height="128dp"
android:layout_height="160dp"
android:layout_gravity="bottom"
android:background="@drawable/scrim"/>

Expand All @@ -54,7 +56,8 @@
android:clipToPadding="false"
android:paddingBottom="@dimen/activity_margin_content"
android:paddingTop="@dimen/activity_margin_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:listItem="@layout/item_dessert"/>

<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
Expand All @@ -63,6 +66,7 @@
android:clickable="true"
android:src="@drawable/ic_action_add"
app:backgroundTint="#279AF1"
app:fabSize="normal"
app:layout_anchor="@+id/appbar"
app:layout_anchorGravity="bottom|right|end"/>

Expand Down
1 change: 1 addition & 0 deletions MaterialSample/app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<dimen name="toolbar_double_height">112dp</dimen>
<dimen name="appbar_padding_top">8dp</dimen>
<dimen name="appbar_header_height">256dp</dimen>
<dimen name="activity_margin_half">8dp</dimen>
<dimen name="activity_margin_content">24dp</dimen>

Expand Down

0 comments on commit 692eec3

Please sign in to comment.