コード例 #1
0
ファイル: TargetDrawable.cs プロジェクト: zhouweiaccp/XobotOS
 /// <summary>Makes drawables in a StateListDrawable all the same dimensions.</summary>
 /// <remarks>
 /// Makes drawables in a StateListDrawable all the same dimensions.
 /// If not a StateListDrawable, then justs sets the bounds to the intrinsic size of the
 /// drawable.
 /// </remarks>
 private void resizeDrawables()
 {
     if (mDrawable is android.graphics.drawable.StateListDrawable)
     {
         android.graphics.drawable.StateListDrawable d = (android.graphics.drawable.StateListDrawable
                                                          )mDrawable;
         int maxWidth  = 0;
         int maxHeight = 0;
         {
             for (int i = 0; i < d.getStateCount(); i++)
             {
                 android.graphics.drawable.Drawable childDrawable = d.getStateDrawable(i);
                 maxWidth  = System.Math.Max(maxWidth, childDrawable.getIntrinsicWidth());
                 maxHeight = System.Math.Max(maxHeight, childDrawable.getIntrinsicHeight());
             }
         }
         d.setBounds(0, 0, maxWidth, maxHeight);
         {
             for (int i_1 = 0; i_1 < d.getStateCount(); i_1++)
             {
                 android.graphics.drawable.Drawable childDrawable = d.getStateDrawable(i_1);
                 childDrawable.setBounds(0, 0, maxWidth, maxHeight);
             }
         }
     }
     else
     {
         if (mDrawable != null)
         {
             mDrawable.setBounds(0, 0, mDrawable.getIntrinsicWidth(), mDrawable.getIntrinsicHeight
                                     ());
         }
     }
 }
コード例 #2
0
ファイル: TargetDrawable.cs プロジェクト: zhouweiaccp/XobotOS
 public virtual void setState(int[] state)
 {
     if (mDrawable is android.graphics.drawable.StateListDrawable)
     {
         android.graphics.drawable.StateListDrawable d = (android.graphics.drawable.StateListDrawable
                                                          )mDrawable;
         d.setState(state);
     }
 }
コード例 #3
0
ファイル: TargetDrawable.cs プロジェクト: zhouweiaccp/XobotOS
 public virtual bool hasState(int[] state)
 {
     if (mDrawable is android.graphics.drawable.StateListDrawable)
     {
         android.graphics.drawable.StateListDrawable d = (android.graphics.drawable.StateListDrawable
                                                          )mDrawable;
         // TODO: this doesn't seem to work
         return(d.getStateDrawableIndex(state) != -1);
     }
     return(false);
 }
コード例 #4
0
 internal StateListState(android.graphics.drawable.StateListDrawable.StateListState
                         orig, android.graphics.drawable.StateListDrawable owner, android.content.res.Resources
                         res) : base(orig, owner, res)
 {
     if (orig != null)
     {
         mStateSets = orig.mStateSets;
     }
     else
     {
         mStateSets = new int[getChildren().Length][];
     }
 }
コード例 #5
0
ファイル: TargetDrawable.cs プロジェクト: zhouweiaccp/XobotOS
 /// <summary>Returns true if the drawable is a StateListDrawable and is in the focused state.
 ///     </summary>
 /// <remarks>Returns true if the drawable is a StateListDrawable and is in the focused state.
 ///     </remarks>
 /// <returns></returns>
 public virtual bool isActive()
 {
     if (mDrawable is android.graphics.drawable.StateListDrawable)
     {
         android.graphics.drawable.StateListDrawable d = (android.graphics.drawable.StateListDrawable
                                                          )mDrawable;
         int[] states = d.getState();
         {
             for (int i = 0; i < states.Length; i++)
             {
                 if (states[i] == android.R.attr.state_focused)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
コード例 #6
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;
		}