Skip to content

Commit

Permalink
Fix collapsing toolbar issue
Browse files Browse the repository at this point in the history
  • Loading branch information
AliMehrpour committed May 24, 2016
1 parent cfb71ba commit bc25f8e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.volcano.esecurebox.R;
import com.volcano.esecurebox.analytics.MixpanelManager;
import com.volcano.esecurebox.fragment.DisplayAccountFragment;
import com.volcano.esecurebox.util.CompatUtils;
import com.volcano.esecurebox.widget.FloatingActionButton;

/**
Expand All @@ -39,7 +40,7 @@ protected void onCreate(Bundle savedInstanceState) {
collapsingToolbar.setTitle(intent.getStringExtra(Intents.EXTRA_ACCOUNT_TITLE));
collapsingToolbar.setContentScrimColor(colorId);
collapsingToolbar.setStatusBarScrimColor(colorId);
collapsingToolbar.setExpandedTitleColor(getResources().getColor(android.R.color.transparent));
collapsingToolbar.setExpandedTitleColor(CompatUtils.getColor(android.R.color.transparent));
collapsingToolbar.setExpandedTitleTextAppearance(R.style.Text_RegularWhite30);

final AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appbar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public Dialog onCreateDialog(final Bundle savedInstanceState) {
final Dialog dialog = new Dialog(getActivity());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(root);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.YELLOW));
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.WHITE));
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

return dialog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
import android.util.AttributeSet;
import android.view.View;

import com.volcano.esecurebox.R;
import com.volcano.esecurebox.VlApplication;

/**
* Defines fab behavior when user scroll the list and coordinator layout has been changed
*/
@SuppressWarnings("unused")
public final class FloatingActionButtonAppBarBehavior extends Behavior<FloatingActionButton> {
final int sCollapsedToolbarHeight = VlApplication.getInstance().getResources().getDimensionPixelSize(R.dimen.toolbar_collapse_height);

public FloatingActionButtonAppBarBehavior(Context context, AttributeSet attrs) {
}
Expand All @@ -23,13 +27,13 @@ public boolean layoutDependsOn(CoordinatorLayout parent, FloatingActionButton ch
}

@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child, View dependency) {
public boolean onDependentViewChanged(CoordinatorLayout parent, final FloatingActionButton child, View dependency) {
final Rect rect = new Rect();
dependency.getGlobalVisibleRect(rect);

child.setTranslationY(dependency.getTop());

if (child.getHeight() + 50 > rect.height()) {
if (rect.height() < sCollapsedToolbarHeight * 2) {
child.setTranslationX(-500); // Just goes out of screen
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="192dp"
android:layout_height="@dimen/toolbar_extended_height"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="48dp"
Expand Down
7 changes: 4 additions & 3 deletions eSecureBox/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@
<dimen name="text_size_36">36sp</dimen>

<dimen name="text_view_height">64dp</dimen>

<dimen name="toolbar_extended_height">192dp</dimen>
<dimen name="toolbar_extended_button_margin_top">164dp</dimen>

<dimen name="toolbar_collapse_height">56dp</dimen>
<dimen name="toolbar_extended_height">208dp</dimen>
<dimen name="toolbar_extended_button_margin_top">156dp</dimen>

</resources>

0 comments on commit bc25f8e

Please sign in to comment.