fix new posts centered layout
This commit is contained in:
parent
4e17256cfa
commit
0df1bcce31
|
@ -208,26 +208,6 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab
|
||||||
error.showToast(getContext());
|
error.showToast(getContext());
|
||||||
}
|
}
|
||||||
}).exec(accountID);
|
}).exec(accountID);
|
||||||
|
|
||||||
ViewTreeObserver vto = view.getViewTreeObserver();
|
|
||||||
if (vto.isAlive()) {
|
|
||||||
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
|
||||||
HomeTabFragment.this.onGlobalLayout();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onGlobalLayout() {
|
|
||||||
switcher.setPivotX(V.dp(28)); // padding + half of icon
|
|
||||||
switcher.setPivotY(switcher.getHeight() / 2f);
|
|
||||||
// toolbar frame goes from screen edge to beginning of right-aligned option buttons.
|
|
||||||
// centering button by applying the same space on the left
|
|
||||||
int padding = getToolbar().getWidth() - toolbarFrame.getWidth();
|
|
||||||
((FrameLayout) toolbarShowNewPostsBtn.getParent()).setPaddingRelative(padding, 0, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateToolbarLogo(){
|
public void updateToolbarLogo(){
|
||||||
|
@ -269,6 +249,28 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab
|
||||||
}
|
}
|
||||||
|
|
||||||
showNewPostsButton();
|
showNewPostsButton();
|
||||||
|
|
||||||
|
ViewTreeObserver vto = toolbar.getViewTreeObserver();
|
||||||
|
if (vto.isAlive()) {
|
||||||
|
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
int toolbarWidth = getToolbar().getWidth();
|
||||||
|
if (toolbarWidth == 0) return;
|
||||||
|
toolbar.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||||
|
|
||||||
|
int toolbarFrameWidth = toolbarFrame.getWidth();
|
||||||
|
int padding = toolbarWidth - toolbarFrameWidth;
|
||||||
|
// toolbar frame goes from screen edge to beginning of right-aligned option buttons.
|
||||||
|
// centering button by applying the same space on the left
|
||||||
|
((FrameLayout) toolbarShowNewPostsBtn.getParent()).setPaddingRelative(padding, 0, 0, 0);
|
||||||
|
toolbarShowNewPostsBtn.setMaxWidth(toolbarWidth - padding * 2);
|
||||||
|
|
||||||
|
switcher.setPivotX(V.dp(28)); // padding + half of icon
|
||||||
|
switcher.setPivotY(switcher.getHeight() / 2f);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -44,7 +44,12 @@
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/show_new_posts_btn"
|
android:id="@+id/show_new_posts_btn"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="32sp"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingVertical="0dp"
|
||||||
|
android:lineSpacingMultiplier="0.8"
|
||||||
|
android:minHeight="32sp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="marquee"
|
||||||
android:textAppearance="@style/m3_title_medium"
|
android:textAppearance="@style/m3_title_medium"
|
||||||
android:text="@string/see_new_posts"
|
android:text="@string/see_new_posts"
|
||||||
android:textColor="@color/gray_25"
|
android:textColor="@color/gray_25"
|
||||||
|
|
Loading…
Reference in New Issue