clean up horizontal card layout
This commit is contained in:
parent
023b4a1184
commit
94f5478316
5 changed files with 15 additions and 10 deletions
|
|
@ -35,7 +35,7 @@ public class HorizontalAlbumAdapter extends AlbumAdapter {
|
||||||
@Override
|
@Override
|
||||||
protected void setColors(int color, ViewHolder holder) {
|
protected void setColors(int color, ViewHolder holder) {
|
||||||
if (holder.itemView != null) {
|
if (holder.itemView != null) {
|
||||||
CardView card=(CardView)holder.itemView;
|
CardView card = (CardView) holder.itemView;
|
||||||
card.setCardBackgroundColor(color);
|
card.setCardBackgroundColor(color);
|
||||||
if (holder.title != null) {
|
if (holder.title != null) {
|
||||||
holder.title.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
|
holder.title.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||||
|
|
@ -79,6 +79,6 @@ public class HorizontalAlbumAdapter extends AlbumAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemViewType(int position) {
|
public int getItemViewType(int position) {
|
||||||
return HorizontalAdapterHelper.getItemViewtype(position, getItemCount());
|
return HorizontalAdapterHelper.getItemViewType(position, getItemCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@ public class HorizontalAdapterHelper {
|
||||||
|
|
||||||
public static void applyMarginToLayoutParams(Context context, ViewGroup.MarginLayoutParams layoutParams, int viewType) {
|
public static void applyMarginToLayoutParams(Context context, ViewGroup.MarginLayoutParams layoutParams, int viewType) {
|
||||||
int listMargin = context.getResources().getDimensionPixelSize(R.dimen.default_item_margin);
|
int listMargin = context.getResources().getDimensionPixelSize(R.dimen.default_item_margin);
|
||||||
|
|
||||||
|
layoutParams.leftMargin = listMargin / 3;
|
||||||
|
layoutParams.rightMargin = listMargin / 3;
|
||||||
if (viewType == TYPE_FIRST) {
|
if (viewType == TYPE_FIRST) {
|
||||||
layoutParams.leftMargin = listMargin;
|
layoutParams.leftMargin = listMargin;
|
||||||
} else if (viewType == TYPE_LAST) {
|
} else if (viewType == TYPE_LAST) {
|
||||||
|
|
@ -21,11 +24,13 @@ public class HorizontalAdapterHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getItemViewtype(int position, int itemCount) {
|
public static int getItemViewType(int position, int itemCount) {
|
||||||
if (position == 0) {
|
if (position == 0) {
|
||||||
return TYPE_FIRST;
|
return TYPE_FIRST;
|
||||||
} else if (position == itemCount - 1) {
|
} else if (position == itemCount - 1) {
|
||||||
return TYPE_LAST;
|
return TYPE_LAST;
|
||||||
} else return TYPE_MIDDLE;
|
} else {
|
||||||
|
return TYPE_MIDDLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,13 +160,12 @@
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/albums"
|
android:id="@+id/albums"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="164dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:scrollbars="none" />
|
android:scrollbars="none" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="2dp"
|
android:layout_height="1dp"
|
||||||
android:background="?attr/dividerColor" />
|
android:background="?attr/dividerColor" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="104dp"
|
android:layout_width="104dp"
|
||||||
android:layout_height="148dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_margin="16dp"
|
||||||
android:foreground="?attr/rectSelectorStrong"
|
android:foreground="?attr/rectSelectorStrong"
|
||||||
app:cardBackgroundColor="?cardBackgroundColor">
|
app:cardBackgroundColor="?cardBackgroundColor">
|
||||||
|
|
||||||
|
|
@ -30,6 +30,8 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="8dp"
|
android:paddingLeft="8dp"
|
||||||
android:paddingRight="8dp"
|
android:paddingRight="8dp"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
android:paddingBottom="4dp"
|
||||||
tools:ignore="UnusedAttribute">
|
tools:ignore="UnusedAttribute">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical|start"
|
android:layout_gravity="center_vertical|start"
|
||||||
android:layout_marginStart="-8dp"
|
|
||||||
android:tint="?attr/iconColor"
|
android:tint="?attr/iconColor"
|
||||||
android:tintMode="src_in"
|
android:tintMode="src_in"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue