mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +00:00
Improve width calculation for span count.
This commit is contained in:
@@ -143,8 +143,9 @@ public class EmojiPageView extends RecyclerView implements VariationSelectorList
|
|||||||
@Override
|
@Override
|
||||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||||
if (layoutManager instanceof GridLayoutManager) {
|
if (layoutManager instanceof GridLayoutManager) {
|
||||||
|
int viewWidth = w - getPaddingStart() - getPaddingEnd();
|
||||||
int idealWidth = getContext().getResources().getDimensionPixelOffset(R.dimen.emoji_drawer_item_width);
|
int idealWidth = getContext().getResources().getDimensionPixelOffset(R.dimen.emoji_drawer_item_width);
|
||||||
int spanCount = Math.max(w / idealWidth, 1);
|
int spanCount = Math.max(viewWidth / idealWidth, 1);
|
||||||
|
|
||||||
((GridLayoutManager) layoutManager).setSpanCount(spanCount);
|
((GridLayoutManager) layoutManager).setSpanCount(spanCount);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user