コード例 #1
0
 private void updateReferenceToIndicatorDrawable(android.graphics.drawable.Drawable
                                                 backgroundDrawable)
 {
     if (backgroundDrawable is android.graphics.drawable.LayerDrawable)
     {
         android.graphics.drawable.LayerDrawable layerDrawable = (android.graphics.drawable.LayerDrawable
                                                                  )backgroundDrawable;
         mIndicatorDrawable = layerDrawable.findDrawableByLayerId([email protected]
                                                                  );
     }
     else
     {
         mIndicatorDrawable = null;
     }
 }
コード例 #2
0
		/// 
		/// <summary>
		/// This method returns the given drawable with a number on it.
		/// </summary>
		/// <param name="baseDrawable">
		///            Drawable to which number will be added </param>
		/// <param name="number">
		///            An integer which will be expressed by the drawable </param>
		/// <param name="shiftFromLeft">
		///            Left margin of number drawable </param>
		/// <param name="shiftFromBottom">
		///            Bottom margin of number drawable </param>
		/// <param name="context">
		///            The base context </param>
		/// <returns> Drawable with number </returns>
		public static Drawable getDrawableWithNumber(Drawable baseDrawable, int number, int shiftFromLeft, int shiftFromBottom, Context context)
		{

			if (number < 0 || number > 9)
			{
				number = 0;
			}
			int textSize = context.Resources.getDimensionPixelSize(R.dimen.number_icon_text_size);

			// TODO: Remove hardcoded text drawable color
			TextDrawable textDrawable = new TextDrawable(number.ToString(), textSize, Color.WHITE);
			Drawable numberDrawable = context.Resources.getDrawable(R.drawable.number_round);

			textDrawable.setBounds(0, 0, numberDrawable.IntrinsicWidth, numberDrawable.IntrinsicHeight);

			Drawable[] drawables = new Drawable[] {baseDrawable, numberDrawable, textDrawable};
			LayerDrawable layerDrawable = new LayerDrawable(drawables);
			layerDrawable.setLayerInset(1, shiftFromLeft, 0, 0, shiftFromBottom);
			layerDrawable.setLayerInset(2, shiftFromLeft, 0, 0, shiftFromBottom);

			return layerDrawable;
		}
コード例 #3
0
        ///
        /// <summary>
        /// This method returns the given drawable with a number on it.
        /// </summary>
        /// <param name="baseDrawable">
        ///            Drawable to which number will be added </param>
        /// <param name="number">
        ///            An integer which will be expressed by the drawable </param>
        /// <param name="shiftFromLeft">
        ///            Left margin of number drawable </param>
        /// <param name="shiftFromBottom">
        ///            Bottom margin of number drawable </param>
        /// <param name="context">
        ///            The base context </param>
        /// <returns> Drawable with number </returns>
        public static Drawable getDrawableWithNumber(Drawable baseDrawable, int number, int shiftFromLeft, int shiftFromBottom, Context context)
        {
            if (number < 0 || number > 9)
            {
                number = 0;
            }
            int textSize = context.Resources.getDimensionPixelSize(R.dimen.number_icon_text_size);

            // TODO: Remove hardcoded text drawable color
            TextDrawable textDrawable   = new TextDrawable(number.ToString(), textSize, Color.WHITE);
            Drawable     numberDrawable = context.Resources.getDrawable(R.drawable.number_round);

            textDrawable.setBounds(0, 0, numberDrawable.IntrinsicWidth, numberDrawable.IntrinsicHeight);

            Drawable[]    drawables     = new Drawable[] { baseDrawable, numberDrawable, textDrawable };
            LayerDrawable layerDrawable = new LayerDrawable(drawables);

            layerDrawable.setLayerInset(1, shiftFromLeft, 0, 0, shiftFromBottom);
            layerDrawable.setLayerInset(2, shiftFromLeft, 0, 0, shiftFromBottom);

            return(layerDrawable);
        }
コード例 #4
0
ファイル: Drawable.cs プロジェクト: hakeemsm/XobotOS
		/// <summary>Create from inside an XML document.</summary>
		/// <remarks>
		/// Create from inside an XML document.  Called on a parser positioned at
		/// a tag in an XML document, tries to create a Drawable from that tag.
		/// Returns null if the tag is not a valid drawable.
		/// </remarks>
		/// <exception cref="org.xmlpull.v1.XmlPullParserException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		public static android.graphics.drawable.Drawable createFromXmlInner(android.content.res.Resources
			 r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs)
		{
			android.graphics.drawable.Drawable drawable;
			string name = parser.getName();
			if (name.Equals("selector"))
			{
				drawable = new android.graphics.drawable.StateListDrawable();
			}
			else
			{
				if (name.Equals("level-list"))
				{
					drawable = new android.graphics.drawable.LevelListDrawable();
				}
				else
				{
					if (name.Equals("layer-list"))
					{
						drawable = new android.graphics.drawable.LayerDrawable();
					}
					else
					{
						if (name.Equals("transition"))
						{
							drawable = new android.graphics.drawable.TransitionDrawable();
						}
						else
						{
							if (name.Equals("color"))
							{
								drawable = new android.graphics.drawable.ColorDrawable();
							}
							else
							{
								if (name.Equals("shape"))
								{
									drawable = new android.graphics.drawable.GradientDrawable();
								}
								else
								{
									if (name.Equals("scale"))
									{
										drawable = new android.graphics.drawable.ScaleDrawable();
									}
									else
									{
										if (name.Equals("clip"))
										{
											drawable = new android.graphics.drawable.ClipDrawable();
										}
										else
										{
											if (name.Equals("rotate"))
											{
												drawable = new android.graphics.drawable.RotateDrawable();
											}
											else
											{
												if (name.Equals("animated-rotate"))
												{
													drawable = new android.graphics.drawable.AnimatedRotateDrawable();
												}
												else
												{
													if (name.Equals("animation-list"))
													{
														drawable = new android.graphics.drawable.AnimationDrawable();
													}
													else
													{
														if (name.Equals("inset"))
														{
															drawable = new android.graphics.drawable.InsetDrawable();
														}
														else
														{
															if (name.Equals("bitmap"))
															{
																drawable = new android.graphics.drawable.BitmapDrawable(r);
																if (r != null)
																{
																	((android.graphics.drawable.BitmapDrawable)drawable).setTargetDensity(r.getDisplayMetrics
																		());
																}
															}
															else
															{
																if (name.Equals("nine-patch"))
																{
																	drawable = new android.graphics.drawable.NinePatchDrawable();
																	if (r != null)
																	{
																		((android.graphics.drawable.NinePatchDrawable)drawable).setTargetDensity(r.getDisplayMetrics
																			());
																	}
																}
																else
																{
																	throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
																		 ": invalid drawable tag " + name);
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			drawable.inflate(r, parser, attrs);
			return drawable;
		}
コード例 #5
0
 internal LayerState(android.graphics.drawable.LayerDrawable.LayerState orig, android.graphics.drawable.LayerDrawable
                     owner, android.content.res.Resources res)
 {
     if (orig != null)
     {
         android.graphics.drawable.LayerDrawable.ChildDrawable[] origChildDrawable = orig.
                                                                                     mChildren;
         int N = orig.mNum;
         mNum      = N;
         mChildren = new android.graphics.drawable.LayerDrawable.ChildDrawable[N];
         mChangingConfigurations         = orig.mChangingConfigurations;
         mChildrenChangingConfigurations = orig.mChildrenChangingConfigurations;
         {
             for (int i = 0; i < N; i++)
             {
                 android.graphics.drawable.LayerDrawable.ChildDrawable r = mChildren[i] = new android.graphics.drawable.LayerDrawable
                                                                                          .ChildDrawable();
                 android.graphics.drawable.LayerDrawable.ChildDrawable or = origChildDrawable[i];
                 if (res != null)
                 {
                     r.mDrawable = or.mDrawable.getConstantState().newDrawable(res);
                 }
                 else
                 {
                     r.mDrawable = or.mDrawable.getConstantState().newDrawable();
                 }
                 r.mDrawable.setCallback(owner);
                 r.mInsetL = or.mInsetL;
                 r.mInsetT = or.mInsetT;
                 r.mInsetR = or.mInsetR;
                 r.mInsetB = or.mInsetB;
                 r.mId     = or.mId;
             }
         }
         mHaveOpacity          = orig.mHaveOpacity;
         mOpacity              = orig.mOpacity;
         mHaveStateful         = orig.mHaveStateful;
         mStateful             = orig.mStateful;
         mCheckedConstantState = mCanConstantState = true;
     }
     else
     {
         mNum      = 0;
         mChildren = null;
     }
 }