当前位置: 首页>>代码示例>>C#>>正文


C# android.getDisplayMetrics方法代码示例

本文整理汇总了C#中android.getDisplayMetrics方法的典型用法代码示例。如果您正苦于以下问题:C# android.getDisplayMetrics方法的具体用法?C# android.getDisplayMetrics怎么用?C# android.getDisplayMetrics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android的用法示例。


在下文中一共展示了android.getDisplayMetrics方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: decodeResourceStream

		// do nothing here
		/// <summary>Decode a new Bitmap from an InputStream.</summary>
		/// <remarks>
		/// Decode a new Bitmap from an InputStream. This InputStream was obtained from
		/// resources, which we pass to be able to scale the bitmap accordingly.
		/// </remarks>
		public static android.graphics.Bitmap decodeResourceStream(android.content.res.Resources
			 res, android.util.TypedValue value, java.io.InputStream @is, android.graphics.Rect
			 pad, android.graphics.BitmapFactory.Options opts)
		{
			if (opts == null)
			{
				opts = new android.graphics.BitmapFactory.Options();
			}
			if (opts.inDensity == 0 && value != null)
			{
				int density = value.density;
				if (density == android.util.TypedValue.DENSITY_DEFAULT)
				{
					opts.inDensity = android.util.DisplayMetrics.DENSITY_DEFAULT;
				}
				else
				{
					if (density != android.util.TypedValue.DENSITY_NONE)
					{
						opts.inDensity = density;
					}
				}
			}
			if (opts.inTargetDensity == 0 && res != null)
			{
				opts.inTargetDensity = res.getDisplayMetrics().densityDpi;
			}
			return decodeStream(@is, pad, opts);
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:35,代码来源:BitmapFactory.cs

示例2: createFromXmlInner

		/// <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)
//.........这里部分代码省略.........
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:101,代码来源:Drawable.cs

示例3: inflate

		public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
			 parser, android.util.AttributeSet attrs)
		{
			base.inflate(r, parser, attrs);
			android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected]
				styleable.BitmapDrawable);
			int id = a.getResourceId([email protected]_src, 0);
			if (id == 0)
			{
				throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
					 ": <bitmap> requires a valid src attribute");
			}
			android.graphics.Bitmap bitmap = android.graphics.BitmapFactory.decodeResource(r, 
				id);
			if (bitmap == null)
			{
				throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
					 ": <bitmap> requires a valid src attribute");
			}
			mBitmapState.mBitmap = bitmap;
			setBitmap(bitmap);
			setTargetDensity(r.getDisplayMetrics());
			android.graphics.Paint paint = mBitmapState.mPaint;
			paint.setAntiAlias(a.getBoolean([email protected]_antialias
				, paint.isAntiAlias()));
			paint.setFilterBitmap(a.getBoolean([email protected]_filter
				, paint.isFilterBitmap()));
			paint.setDither(a.getBoolean([email protected]_dither, 
				paint.isDither()));
			setGravity(a.getInt([email protected]_gravity, android.view.Gravity
				.FILL));
			int tileMode = a.getInt([email protected]_tileMode, -1
				);
			if (tileMode != -1)
			{
				switch (tileMode)
				{
					case 0:
					{
						setTileModeXY(android.graphics.Shader.TileMode.CLAMP, android.graphics.Shader.TileMode
							.CLAMP);
						break;
					}

					case 1:
					{
						setTileModeXY(android.graphics.Shader.TileMode.REPEAT, android.graphics.Shader.TileMode
							.REPEAT);
						break;
					}

					case 2:
					{
						setTileModeXY(android.graphics.Shader.TileMode.MIRROR, android.graphics.Shader.TileMode
							.MIRROR);
						break;
					}
				}
			}
			a.recycle();
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:61,代码来源:BitmapDrawable.cs

示例4: BitmapDrawable

		internal BitmapDrawable(android.graphics.drawable.BitmapDrawable.BitmapState state
			, android.content.res.Resources res)
		{
			mBitmapState = state;
			if (res != null)
			{
				mTargetDensity = res.getDisplayMetrics().densityDpi;
			}
			else
			{
				mTargetDensity = state.mTargetDensity;
			}
			setBitmap(state != null ? state.mBitmap : null);
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:14,代码来源:BitmapDrawable.cs

示例5: setNinePatchState

		internal void setNinePatchState(android.graphics.drawable.NinePatchDrawable.NinePatchState
			 state, android.content.res.Resources res)
		{
			mNinePatchState = state;
			mNinePatch = state.mNinePatch;
			mPadding = state.mPadding;
			mTargetDensity = res != null ? res.getDisplayMetrics().densityDpi : state.mTargetDensity;
			//noinspection PointlessBooleanExpression
			if (state.mDither != DEFAULT_DITHER)
			{
				// avoid calling the setter unless we need to, since it does a
				// lazy allocation of a paint
				setDither(state.mDither);
			}
			if (mNinePatch != null)
			{
				computeBitmapSize();
			}
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:19,代码来源:NinePatchDrawable.cs


注:本文中的android.getDisplayMetrics方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。