示例#1
0
 /**
  * apply background in view. possible type : - COLOR - REF => search for that drawable in
  * resources - BASE64 => convert base64 to bitmap and apply in view
  */
 public static void applyBackground(View view, DynamicProperty property) {
   if (view != null) {
     switch (property.type) {
       case COLOR:
         {
           view.setBackgroundColor(property.getValueColor());
         }
         break;
       case REF:
         {
           view.setBackgroundResource(getDrawableId(view.getContext(), property.getValueString()));
         }
         break;
       case BASE64:
         {
           if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN)
             view.setBackground(property.getValueBitmapDrawable());
           else view.setBackgroundDrawable(property.getValueBitmapDrawable());
         }
         break;
       case DRAWABLE:
         {
           if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN)
             view.setBackground(property.getValueGradientDrawable());
           else view.setBackgroundDrawable(property.getValueGradientDrawable());
         }
         break;
     }
   }
 }
示例#2
0
 /** apply the color in textView */
 public static void applyTextColor(View view, DynamicProperty property) {
   if (view instanceof TextView) {
     switch (property.type) {
       case COLOR:
         {
           ((TextView) view).setTextColor(property.getValueColor());
         }
         break;
     }
   }
 }