Aracılığıyla paylaş


View Constructors

Definition

Overloads

View(Context)

Simple constructor to use when creating a view from code.

View(Context, IAttributeSet)

Constructor that is called when inflating a view from XML.

View(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

View(Context, IAttributeSet, Int32)

Perform inflation from XML and apply a class-specific base style from a theme attribute.

View(Context, IAttributeSet, Int32, Int32)

Perform inflation from XML and apply a class-specific base style from a theme attribute or style resource.

View(Context)

Simple constructor to use when creating a view from code.

[Android.Runtime.Register(".ctor", "(Landroid/content/Context;)V", "")]
public View (Android.Content.Context? context);
[<Android.Runtime.Register(".ctor", "(Landroid/content/Context;)V", "")>]
new Android.Views.View : Android.Content.Context -> Android.Views.View

Parameters

context
Context

The Context the view is running in, through which it can access the current theme, resources, etc.

Attributes

Remarks

Simple constructor to use when creating a view from code.

Java documentation for android.view.View.View(android.content.Context).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

View(Context, IAttributeSet)

Constructor that is called when inflating a view from XML.

[Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;)V", "")]
public View (Android.Content.Context? context, Android.Util.IAttributeSet? attrs);
[<Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;)V", "")>]
new Android.Views.View : Android.Content.Context * Android.Util.IAttributeSet -> Android.Views.View

Parameters

context
Context

The Context the view is running in, through which it can access the current theme, resources, etc.

attrs
IAttributeSet

The attributes of the XML tag that is inflating the view.

Attributes

Remarks

Constructor that is called when inflating a view from XML. This is called when a view is being constructed from an XML file, supplying attributes that were specified in the XML file. This version uses a default style of 0, so the only attribute values applied are those in the Context's Theme and the given AttributeSet.

The method onFinishInflate() will be called after all children have been added.

Java documentation for android.view.View.View(android.content.Context, android.util.AttributeSet).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

  • <xref:Android.Views.View(Android.Content.Context%2c+Android.Util.IAttributeSet%2c+Android.Util.IAttributeSet)>

Applies to

View(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

protected View (IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer);
new Android.Views.View : nativeint * Android.Runtime.JniHandleOwnership -> Android.Views.View

Parameters

javaReference
IntPtr

nativeint

A IntPtrcontaining a Java Native Interface (JNI) object reference.

transfer
JniHandleOwnership

A JniHandleOwnershipindicating how to handle javaReference

Remarks

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

View(Context, IAttributeSet, Int32)

Perform inflation from XML and apply a class-specific base style from a theme attribute.

[Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "")]
public View (Android.Content.Context? context, Android.Util.IAttributeSet? attrs, int defStyleAttr);
[<Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "")>]
new Android.Views.View : Android.Content.Context * Android.Util.IAttributeSet * int -> Android.Views.View

Parameters

context
Context

The Context the view is running in, through which it can access the current theme, resources, etc.

attrs
IAttributeSet

The attributes of the XML tag that is inflating the view.

defStyleAttr
Int32

An attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.

Attributes

Remarks

Perform inflation from XML and apply a class-specific base style from a theme attribute. This constructor of View allows subclasses to use their own base style when they are inflating. For example, a Button class's constructor would call this version of the super class constructor and supply R.attr.buttonStyle for <var>defStyleAttr</var>; this allows the theme's button style to modify all of the base view attributes (in particular its background) as well as the Button class's attributes.

Java documentation for android.view.View.View(android.content.Context, android.util.AttributeSet, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

  • <xref:Android.Views.View(Android.Content.Context%2c+Android.Util.IAttributeSet)>

Applies to

View(Context, IAttributeSet, Int32, Int32)

Perform inflation from XML and apply a class-specific base style from a theme attribute or style resource.

[Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;II)V", "")]
public View (Android.Content.Context? context, Android.Util.IAttributeSet? attrs, int defStyleAttr, int defStyleRes);
[<Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;II)V", "")>]
new Android.Views.View : Android.Content.Context * Android.Util.IAttributeSet * int * int -> Android.Views.View

Parameters

context
Context

The Context the view is running in, through which it can access the current theme, resources, etc.

attrs
IAttributeSet

The attributes of the XML tag that is inflating the view.

defStyleAttr
Int32

An attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.

defStyleRes
Int32

A resource identifier of a style resource that supplies default values for the view, used only if defStyleAttr is 0 or can not be found in the theme. Can be 0 to not look for defaults.

Attributes

Remarks

Perform inflation from XML and apply a class-specific base style from a theme attribute or style resource. This constructor of View allows subclasses to use their own base style when they are inflating.

When determining the final value of a particular attribute, there are four inputs that come into play: <ol> <li>Any attribute values in the given AttributeSet. <li>The style resource specified in the AttributeSet (named "style"). <li>The default style specified by <var>defStyleAttr</var>. <li>The default style specified by <var>defStyleRes</var>. <li>The base values in this theme. </ol>

Each of these inputs is considered in-order, with the first listed taking precedence over the following ones. In other words, if in the AttributeSet you have supplied &lt;Button * textColor="#ff000000"&gt; , then the button's text will <em>always</em> be black, regardless of what is specified in any of the styles.

Java documentation for android.view.View.View(android.content.Context, android.util.AttributeSet, int, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

  • <xref:Android.Views.View(Android.Content.Context%2c+Android.Util.IAttributeSet%2c+Android.Util.IAttributeSet)>

Applies to