add some background and foreground effect to list items

This commit is contained in:
tibbi 2016-11-23 20:20:18 +01:00
parent 0fb3f20a2b
commit bd033389f0
6 changed files with 71 additions and 40 deletions

View File

@ -23,6 +23,7 @@ class EventsAdapter(val activity: SimpleActivity, val mItems: List<Event>, val i
val markedItems = HashSet<Int>()
fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) {
itemView.event_item_frame.isSelected = select
if (pos == -1)
return

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<selector>
<item
android:drawable="@color/activated_item_foreground"
android:state_selected="true"/>
</selector>
</item>
<item>
<ripple android:color="@color/pressed_item_foreground">
<item android:id="@android:id/mask">
<color android:color="@android:color/white"/>
</item>
</ripple>
</item>
</layer-list>

View File

@ -2,5 +2,5 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="@color/dark_grey_pressed_mask"/>
android:color="@color/mediumGrey"/>
</shape>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/pressed_item_foreground" android:state_pressed="true"/>
<item android:drawable="@color/activated_item_foreground" android:state_selected="true"/>
</selector>

View File

@ -1,10 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/event_item_holder"
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/event_item_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:foreground="@drawable/selector">
<RelativeLayout
android:id="@+id/event_item_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/event_item_background"
android:paddingBottom="@dimen/event_padding"
android:paddingTop="@dimen/event_padding">
@ -46,3 +52,4 @@
android:textSize="@dimen/day_text_size"/>
</RelativeLayout>
</FrameLayout>

View File

@ -4,7 +4,8 @@
<color name="colorPrimaryDark">#ffe27725</color>
<color name="colorAccent">@color/colorPrimary</color>
<color name="dark_grey_pressed_mask">#11000000</color>
<color name="pressed_item_foreground">#08000000</color>
<color name="activated_item_foreground">#44888888</color>
<color name="mediumGrey">#18000000</color>
<color name="divider_grey">#44cccccc</color>
</resources>