android - Change Layout Background Drawable Color based on Value -


so have android application in sliders used set value multiple parameters. using "google cards" type of layout each slider box. each card own relative layout contained within linearlayout placed within scrollview. change color of card based on value user sets in card, however, problem have color background defined in xml card design.

how can change color in xml card design based on value user puts in on slider? also, there way have gradient effect when changing colors. example, 0 strong red, while 10 strong green, 5 yellow , 2.5 mix between red , yellow , 7.5 mix between yellow , green.

xml layout background:

<?xml version="1.0" encoding="utf-8"?>  <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item>     <shape android:shape="rectangle"         android:dither="true">         <corners android:radius="2dp"/>         <solid android:color="#ccc"/>     </shape> </item>  <item android:bottom="2dp">     <shape android:shape="rectangle"         android:dither="true">         <corners android:radius="2dp"/>         <solid android:color="@android:color/white"/>          <padding android:bottom="8dp"             android:left="8dp"             android:right="8dp"             android:top="8dp"/>     </shape> </item> </layer-list> 

relative layout xml:

<relativelayout                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:background="@drawable/bg_card"                 android:layout_marginbottom="4dp"                 android:layout_marginleft="6dp"                 android:layout_marginright="6dp"                 android:layout_margintop="4dp"                 android:id="@+id/infolayout"> </relativelayout> 

what card looks like:

what card looks like


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -