Compact card view

This commit is contained in:
M66B 2019-08-14 20:08:12 +02:00
parent 36e923695d
commit be9fd41366
1 changed files with 3 additions and 2 deletions

View File

@ -49,16 +49,17 @@ public class ViewCardOptional extends CardView {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean cards = prefs.getBoolean("cards", true);
boolean compact = prefs.getBoolean("compact", false);
if (cards) {
int dp6 = Helper.dp2pixels(getContext(), 6);
int color = Helper.resolveColor(getContext(), R.attr.colorCardBackground);
FrameLayout.LayoutParams lparam = (FrameLayout.LayoutParams) getLayoutParams();
lparam.setMargins(dp6, dp6, dp6, dp6);
lparam.setMargins(dp6, compact ? 0 : dp6, dp6, dp6);
setLayoutParams(lparam);
setRadius(dp6);
setElevation(dp6);
setElevation(compact ? dp6 / 2f : dp6);
setCardBackgroundColor(color);
getChildAt(0).setPadding(dp6, dp6, dp6, dp6);