Use colorControlHighlight value for selected item background

This commit is contained in:
Shinokuni 2019-12-19 21:17:20 +01:00
parent 850c739b2b
commit 06c1313664
2 changed files with 5 additions and 7 deletions

View File

@ -2,7 +2,6 @@ package com.readrops.app.adapters;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.util.TypedValue;
import android.view.LayoutInflater;
@ -352,17 +351,18 @@ public class MainItemListAdapter extends PagedListAdapter<ItemWithFeed, MainItem
private void setSelected(boolean selected) {
Context context = itemView.getContext();
TypedValue outValue = new TypedValue();
if (selected) {
itemView.setBackground(new ColorDrawable(ContextCompat.getColor(context, R.color.selected_background)));
context.getTheme().resolveAttribute(
android.R.attr.colorControlHighlight, outValue, true);
} else {
TypedValue outValue = new TypedValue();
context.getTheme().resolveAttribute(
android.R.attr.selectableItemBackground, outValue, true);
}
itemView.setBackgroundResource(outValue.resourceId);
}
}
public ImageView getItemImage() {
return binding.itemImage;

View File

@ -6,6 +6,4 @@
<color name="colorControlNormal">#d7d7d7</color>
<color name="colorBackground">#fafafa</color>
<color name="textColorPrimary">#000000</color>
<color name="selected_background">#E0E0E0</color>
</resources>