Beispiel #1
0
        /// <summary>
        /// This method can be extended to get all android attributes color, string, dimension ...etc
        /// </summary>
        /// <param name="context">          used to fetch android attribute </param>
        /// <param name="androidAttribute"> attribute codes like Resource.Attribute.colorAccent </param>
        /// <returns> in this case color of android attribute </returns>
        public static int fetchContextColor(Context context, int androidAttribute)
        {
            TypedValue typedValue = new TypedValue();

            TypedArray a     = context.ObtainStyledAttributes(typedValue.Data, new int[] { androidAttribute });
            int        color = a.GetColor(0, 0);

            a.Recycle();

            return(color);
        }
Beispiel #2
0
 private void InitAttrs(Context context, AttributeSet attrs)
 {
     try
     {
         TypedArray ta = context.ObtainStyledAttributes(attrs, Resource.Styleable.LoadingView);
         int        loadingRendererId = ta.GetInt(Resource.Styleable.LoadingView_loading_renderer, 0);
         LoadingRenderer = LoadingRendererFactory.CreateLoadingRenderer(context, loadingRendererId);
         ta.Recycle();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
         Console.Write(e.StackTrace);
     }
 }
Beispiel #3
0
        private void GetAttrs(Context context, AttributeSet attrs)
        {
            TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.AlphaMaskLayout);

            alphaFrom = a.GetInt(Resource.Styleable.AlphaMaskLayout_aml_alpha_from, DEFAULT_ALPHA_FROM);
            alphaTo   = a.GetInt(Resource.Styleable.AlphaMaskLayout_aml_alpha_to, DEFAULT_ALPHA_TO);
            duration  = a.GetInt(Resource.Styleable.AlphaMaskLayout_aml_duration, DEFAULT_DURATION);
            a.Recycle();

            //init foreground alpha
            if (Foreground == null)
            {
                Foreground = new ColorDrawable(Color.ParseColor(DEFAULT_COLOR));
            }
            Foreground.Alpha = 0;

            CheckAttrsValues();
        }