diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-06-18 14:30:34 +0300 |
---|---|---|
committer | Niedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com> | 2020-06-18 19:04:20 +0300 |
commit | 31f6b851c8ee580c8fc51044c4eebfd99dc85df7 (patch) | |
tree | 4dd9fffe0620d1fd862ebbc7aebb4d15a7b12cb9 /app/src/main/java/it/niedermann/nextcloud/deck/ui/view | |
parent | c6705afde6ac479ac2995dfc66991dfcb788810e (diff) |
Reduce label padding
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/view')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelChip.java | 11 | ||||
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelLayout.java | 9 |
2 files changed, 16 insertions, 4 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelChip.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelChip.java index 8c88fd5cd..581f27d10 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelChip.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelChip.java @@ -8,12 +8,12 @@ import android.text.TextUtils; import android.view.ViewGroup; import androidx.annotation.NonNull; +import androidx.annotation.Px; import com.google.android.flexbox.FlexboxLayout; import com.google.android.material.chip.Chip; import it.niedermann.nextcloud.deck.DeckLog; -import it.niedermann.nextcloud.deck.R; import it.niedermann.nextcloud.deck.model.Label; import it.niedermann.nextcloud.deck.util.ColorUtil; @@ -22,7 +22,7 @@ public class LabelChip extends Chip { private final Label label; - public LabelChip(@NonNull Context context, @NonNull Label label) { + public LabelChip(@NonNull Context context, @NonNull Label label, @Px int gutter) { super(context); this.label = label; @@ -31,9 +31,14 @@ public class LabelChip extends Chip { ViewGroup.LayoutParams.WRAP_CONTENT ); - params.setMargins(0, 0, Math.round(context.getResources().getDimension(R.dimen.spacer_1x)), 0); + params.setMargins(0, 0, gutter, 0); setLayoutParams(params); setEnsureMinTouchTargetSize(false); + setMinHeight(0); + setChipMinHeight(0); + setPadding(0, gutter, 0, gutter); + setChipStartPadding(0); + setChipEndPadding(0); setText(label.getTitle()); setEllipsize(TextUtils.TruncateAt.END); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelLayout.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelLayout.java index d24e463b5..814c63ce1 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelLayout.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/LabelLayout.java @@ -4,6 +4,7 @@ import android.content.Context; import android.util.AttributeSet; import androidx.annotation.NonNull; +import androidx.annotation.Px; import com.google.android.flexbox.FlexboxLayout; @@ -11,14 +12,20 @@ import java.util.LinkedList; import java.util.List; import it.niedermann.nextcloud.deck.DeckLog; +import it.niedermann.nextcloud.deck.R; import it.niedermann.nextcloud.deck.model.Label; +import static it.niedermann.nextcloud.deck.util.DimensionUtil.dpToPx; + public class LabelLayout extends FlexboxLayout { + @Px + private int gutter; private List<LabelChip> chipList = new LinkedList<>(); public LabelLayout(Context context, AttributeSet attrs) { super(context, attrs); + this.gutter = dpToPx(context, R.dimen.spacer_1hx); } /** @@ -75,7 +82,7 @@ public class LabelLayout extends FlexboxLayout { continue labelList; } } - LabelChip chip = new LabelChip(getContext(), label); + LabelChip chip = new LabelChip(getContext(), label, gutter); addView(chip); chipList.add(chip); } |