Merge pull request #11080 from osmandapp/fix-alignment
Fix icon alignment in landscape orientation
This commit is contained in:
commit
0f9d744338
5 changed files with 20 additions and 11 deletions
|
@ -2,8 +2,7 @@
|
|||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="7dp">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/outline"
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<net.osmand.plus.widgets.FlowLayout
|
||||
android:id="@+id/color_items"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="4dp" />
|
||||
android:layout_marginStart="@dimen/list_content_padding"
|
||||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginRight="@dimen/list_content_padding" />
|
||||
</LinearLayout>
|
|
@ -522,8 +522,9 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
|
|||
FlowLayout selectShape = view.findViewById(R.id.select_shape);
|
||||
for (BackgroundType backgroundType : BackgroundType.values()) {
|
||||
if (backgroundType.isSelected()) {
|
||||
int minimalPaddingBetweenIcon = app.getResources().getDimensionPixelSize(R.dimen.favorites_select_icon_button_right_padding);
|
||||
selectShape.addView(createShapeItemView(backgroundType, selectShape),
|
||||
new FlowLayout.LayoutParams(0, 0));
|
||||
new FlowLayout.LayoutParams(minimalPaddingBetweenIcon, 0));
|
||||
selectShape.setHorizontalAutoSpacing(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -431,7 +431,8 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
|
|||
ArrayList<Integer> icons = ProfileIcons.getIcons();
|
||||
for (int iconRes : icons) {
|
||||
View iconItem = createIconItemView(iconRes, iconItems);
|
||||
iconItems.addView(iconItem, new FlowLayout.LayoutParams(0, 0));
|
||||
int minimalPaddingBetweenIcon = app.getResources().getDimensionPixelSize(R.dimen.favorites_select_icon_button_right_padding);
|
||||
iconItems.addView(iconItem, new FlowLayout.LayoutParams(minimalPaddingBetweenIcon, 0));
|
||||
iconItems.setHorizontalAutoSpacing(true);
|
||||
}
|
||||
setIconColor(changedProfile.iconRes);
|
||||
|
|
|
@ -100,25 +100,30 @@ public class FlowLayout extends ViewGroup {
|
|||
verticalPosition += line_height;
|
||||
}
|
||||
child.layout(horizontalPosition - childWidth, verticalPosition, horizontalPosition, verticalPosition + childHeight);
|
||||
horizontalPosition -= childWidth + freeSizeSpacing;
|
||||
horizontalPosition -= freeSizeSpacing;
|
||||
} else {
|
||||
if (horizontalPosition + childWidth > width) {
|
||||
horizontalPosition = getPaddingLeft();
|
||||
verticalPosition += line_height;
|
||||
}
|
||||
child.layout(horizontalPosition, verticalPosition, horizontalPosition + childWidth, verticalPosition + childHeight);
|
||||
horizontalPosition += childWidth + freeSizeSpacing;
|
||||
horizontalPosition += freeSizeSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getFreeSizeSpacing(int width, LayoutParams lp, int childWidth) {
|
||||
int freeSizeSpacing;
|
||||
int itemsCount = width / (childWidth + lp.horizontalSpacing);
|
||||
if (itemsCount > 1 && horizontalAutoSpacing) {
|
||||
return (width % childWidth / (itemsCount - 1)) + lp.horizontalSpacing;
|
||||
freeSizeSpacing = (width - childWidth) / (itemsCount-1);
|
||||
} else if (!horizontalAutoSpacing) {
|
||||
freeSizeSpacing = childWidth + lp.horizontalSpacing;
|
||||
} else {
|
||||
freeSizeSpacing = (width % childWidth / itemsCount);
|
||||
}
|
||||
return lp.horizontalSpacing;
|
||||
return freeSizeSpacing;
|
||||
}
|
||||
|
||||
public static class LayoutParams extends ViewGroup.LayoutParams {
|
||||
|
|
Loading…
Reference in a new issue