本文整理汇总了C#中RelativeLayout.AddView方法的典型用法代码示例。如果您正苦于以下问题:C# RelativeLayout.AddView方法的具体用法?C# RelativeLayout.AddView怎么用?C# RelativeLayout.AddView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RelativeLayout
的用法示例。
在下文中一共展示了RelativeLayout.AddView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetView
public override View GetView (Context context, View convertView, ViewGroup parent)
{
var view = new RelativeLayout(context);
var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent,
ViewGroup.LayoutParams.WrapContent);
view.SetMinimumHeight(150);
parms.SetMargins(5, 3, 5, 0);
parms.AddRule(LayoutRules.AlignParentLeft);
_caption = new TextView (context);
SetCaption (Caption);
view.AddView(_caption, parms);
if (!String.IsNullOrWhiteSpace (Indicator)) {
var tparms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent,
ViewGroup.LayoutParams.WrapContent);
tparms.SetMargins(5, 3, 5, 5);
tparms.AddRule(LayoutRules.CenterVertical);
tparms.AddRule(LayoutRules.AlignParentRight);
_text = new TextView (context) {
Text = Indicator,
TextSize = 22f
};
view.AddView(_text, tparms);
}
return view;
}
示例2: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
RelativeLayout mediarelativelayout =new RelativeLayout(nn_activity);
var mediarelativelayoutparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.MatchParent);
mediarelativelayout.LayoutParameters = mediarelativelayoutparam;
mediarelativelayout.SetBackgroundColor (Color.White);
Button playbut = new Button (nn_activity);
RelativeLayout.LayoutParams playbutparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.MatchParent);
playbut.Alpha = 0;
playbutparam.AddRule(LayoutRules.CenterInParent);
playbut.LayoutParameters = playbutparam;
playbut.Click -=OntouchVideoView;
playbut.Click += OntouchVideoView;
mediarelativelayout.AddView (playbut);
textureview = new TextureView (nn_activity);
textureview.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent);
textureview.Rotation = 90;
textureview.SurfaceTextureListener = this;
mediarelativelayout.AddView (textureview);
return mediarelativelayout;
}
示例3: AddItem
//here we only have img and text for each item
//create a RelativeLayout and add it to dic
//squear image
public void AddItem(int imgresource,string text,Action OnCellClick)
{
RelativeLayout menucell = new RelativeLayout (nn_context);
menucell.SetPadding (TapUtil.dptodx(padding),TapUtil.dptodx(padding),TapUtil.dptodx(padding),TapUtil.dptodx(padding));
menucell.LayoutParameters = new LinearLayout.LayoutParams (TapUtil.dptodx(cellwidth),TapUtil.dptodx(cellheight));
menucell.Click+= (object sender, EventArgs e) => {
if(OnCellClick!=null){
OnCellClick();
}
};
ImageView img = new ImageView (nn_context);
img.Id = TapUtil.generateViewId ();
img.LayoutParameters = new RelativeLayout.LayoutParams (TapUtil.dptodx(imagewidth),TapUtil.dptodx(imagewidth));
// Bitmap.CreateScaledBitmap(imgresource, TapUtil.dptodx(imagewidth), TapUtil.dptodx(imageheight), false);
img.SetImageResource (imgresource);
img.SetBackgroundColor (Color.White);
TextView textview = new TextView (nn_context);
RelativeLayout.LayoutParams textviewparam=new RelativeLayout.LayoutParams (TapUtil.dptodx(textwidth),TapUtil.dptodx(textheight));
textviewparam.AddRule(LayoutRules.RightOf,img.Id);
textviewparam.LeftMargin = TapUtil.dptodx (space);
textview.LayoutParameters =textviewparam;
textview.Text = text;
textview.SetTypeface (Typeface.Default, TypefaceStyle.Bold);
textview.SetTextColor(Color.Black);
textview.Gravity = global::Android.Views.GravityFlags.Center;
menucell.AddView (img);
menucell.AddView (textview);
nn_itemlist.Add (menucell);
}
示例4: HSVColorPickerDialog
public HSVColorPickerDialog(Context context, Color initialColor, Action<Color> listener)
: base(context)
{
this.selectedColor = initialColor;
this.listener = listener;
colorWheel = new HSVColorWheel(context);
valueSlider = new HSVValueSlider(context);
var padding = (int)(context.Resources.DisplayMetrics.Density * PADDING_DP);
var borderSize = (int)(context.Resources.DisplayMetrics.Density * BORDER_DP);
var layout = new RelativeLayout(context);
var lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent);
lp.BottomMargin = (int)(context.Resources.DisplayMetrics.Density * CONTROL_SPACING_DP);
colorWheel.setListener((color) => valueSlider.SetColor(color, true));
colorWheel.setColor(initialColor);
colorWheel.Id = (1);
layout.AddView(colorWheel, lp);
int selectedColorHeight = (int)(context.Resources.DisplayMetrics.Density * SELECTED_COLOR_HEIGHT_DP);
var valueSliderBorder = new FrameLayout(context);
valueSliderBorder.SetBackgroundColor(BORDER_COLOR);
valueSliderBorder.SetPadding(borderSize, borderSize, borderSize, borderSize);
valueSliderBorder.Id = (2);
lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, selectedColorHeight + 2 * borderSize);
lp.BottomMargin = (int)(context.Resources.DisplayMetrics.Density * CONTROL_SPACING_DP);
lp.AddRule(LayoutRules.Below, 1);
layout.AddView(valueSliderBorder, lp);
valueSlider.SetColor(initialColor, false);
valueSlider.SetListener((color) =>
{
selectedColor = color;
selectedColorView.SetBackgroundColor(color);
});
valueSliderBorder.AddView(valueSlider);
var selectedColorborder = new FrameLayout(context);
selectedColorborder.SetBackgroundColor(BORDER_COLOR);
lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, selectedColorHeight + 2 * borderSize);
selectedColorborder.SetPadding(borderSize, borderSize, borderSize, borderSize);
lp.AddRule(LayoutRules.Below, 2);
layout.AddView(selectedColorborder, lp);
selectedColorView = new View(context);
selectedColorView.SetBackgroundColor(selectedColor);
selectedColorborder.AddView(selectedColorView);
SetButton((int)DialogButtonType.Negative, context.GetString(Android.Resource.String.Cancel), ClickListener);
SetButton((int)DialogButtonType.Positive, context.GetString(Android.Resource.String.Ok), ClickListener);
SetView(layout, padding, padding, padding, padding);
}
示例5: AddSpinner
public void AddSpinner(ViewGroup rootview,string loadingtext)
{
loading = true;
if(loadingcontainer==null||(loadingcontainer!=null&&!loadingcontainer.IsShown)){
loadingcontainer = new RelativeLayout (nn_activity);
loadingcontainer.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent);
loadingcontainer.SetBackgroundColor (Color.White);
var detailcontainer = new LinearLayout (nn_activity);
detailcontainer.Orientation = Orientation.Vertical;
RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams ((int)TapUtil.dptodx (100), RelativeLayout.LayoutParams.WrapContent);
param.AddRule (LayoutRules.CenterInParent);
detailcontainer.LayoutParameters = param;
LinearLayout.LayoutParams linearlayoutparm = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
linearlayoutparm.Gravity = GravityFlags.CenterHorizontal;
ProgressBar progressbar = new ProgressBar (nn_activity);
progressbar.LayoutParameters = linearlayoutparm;
TextView tectview = new TextView (nn_activity);
tectview.LayoutParameters = linearlayoutparm;
tectview.Text = loadingtext;
tectview.Gravity = GravityFlags.CenterHorizontal;
detailcontainer.AddView (progressbar);
detailcontainer.AddView (tectview);
loadingcontainer.AddView (detailcontainer);
rootview.AddView (loadingcontainer);
}
}
示例6: Initialize
void Initialize ()
{
this.LayoutParameters = new RelativeLayout.LayoutParams(-1,Configuration.getHeight (412));// LinearLayout.LayoutParams (Configuration.getWidth (582), Configuration.getHeight (394));
this.SetGravity(GravityFlags.Center);
image = new RelativeLayout(context);
txtDescription = new TextView (context);
txtTitle = new TextView (context);
background = new LinearLayout (context);
image.SetGravity (GravityFlags.Center);
background.LayoutParameters = new LinearLayout.LayoutParams (Configuration.getWidth (530), Configuration.getHeight (356));
background.Orientation = Orientation.Vertical;
background.SetBackgroundColor (Color.ParseColor ("#50000000"));
image.LayoutParameters = new RelativeLayout.LayoutParams (Configuration.getWidth (582), Configuration.getHeight (394));
txtTitle.SetTextColor (Color.ParseColor("#ffffff"));
txtDescription.SetTextColor(Color.ParseColor("#ffffff"));
txtTitle.SetTextSize (ComplexUnitType.Px, Configuration.getHeight (40));
txtDescription.SetTextSize (ComplexUnitType.Px, Configuration.getHeight (30));
background.AddView (txtTitle);
background.AddView (txtDescription);
image.AddView (background);
this.AddView (image);
//this.AddView (background);
}
示例7: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
_timestamp = DateTime.Now.ToLongTimeString ();
// create a layout
var rl = new RelativeLayout (this);
var layoutParams = new RelativeLayout.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent);
rl.LayoutParameters = layoutParams;
// get the initial orientation
var surfaceOrientation = this.WindowManager.DefaultDisplay.Rotation;
// create the portrait and landscape layout
_layoutParamsPortrait = new RelativeLayout.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent);
_layoutParamsLandscape = new RelativeLayout.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent);
_layoutParamsLandscape.LeftMargin = 100;
_layoutParamsLandscape.TopMargin = 100;
// create the TextView an assign the initial layout params
_tv = new TextView (this);
if (surfaceOrientation == SurfaceOrientation.Rotation0 || surfaceOrientation == SurfaceOrientation.Rotation180) {
_tv.LayoutParameters = _layoutParamsPortrait;
} else {
_tv.LayoutParameters = _layoutParamsLandscape;
}
_tv.Text = "Programmatic layout. Timestamp = " + _timestamp;
rl.AddView (_tv);
SetContentView (rl);
}
示例8: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
rootview = new RelativeLayout (nn_activity);
rootview.LayoutParameters = new ViewGroup.LayoutParams (ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
listview = new ListView (nn_activity);
listview.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent);
listview.Adapter = new TermsIndexAdapter (nn_activity,nn_adapterlist);
listview.ItemClick-=OnItemClick;
listview.ItemClick+=OnItemClick;
rootview.AddView (listview);
return rootview;
}
示例9: GetView
public override View GetView (Context context, View convertView, ViewGroup parent)
{
TextView tv = new TextView (context);
tv.TextSize = 20f;
tv.SetText (Android.Text.Html.FromHtml (Caption), TextView.BufferType.Spannable);
var parms = new RelativeLayout.LayoutParams (ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
parms.AddRule (LayoutRules.CenterHorizontal);
RelativeLayout view = new RelativeLayout (context, null, Android.Resource.Attribute.ListSeparatorTextViewStyle);
view.AddView (tv, parms);
return view;
}
示例10: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
rootview = new RelativeLayout (nn_activity);
rootview.LayoutParameters = new ViewGroup.LayoutParams (ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
ListView listview = new ListView (nn_activity);
listview.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent);
listview.Adapter = adapter;
rootview.AddView (listview);
LoadTeams ();
return rootview;
}
示例11: GetView
public override View GetView(Context context, View convertView, ViewGroup parent)
{
var view = new RelativeLayout(context);
var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent,
ViewGroup.LayoutParams.WrapContent);
parms.SetMargins(5, 3, 5, 0);
parms.AddRule((int) LayoutRules.CenterVertical);
tv = new TextView(context) {Text = Caption, TextSize = 16f};
view.AddView(tv, parms);
var sparms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent,
ViewGroup.LayoutParams.WrapContent);
sparms.SetMargins(5, 3, 5, 0);
sparms.AddRule((int) LayoutRules.CenterVertical);
sparms.AddRule((int) LayoutRules.AlignParentRight);
sw = new ToggleButton(context) {Tag = 1, Checked = Value};
view.AddView(sw, sparms);
return view;
}
示例12: OnCreate
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
rootview = new RelativeLayout (nn_activity);
rootview.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent);
rootview.Id=TapUtil.generateViewId ();
viewpage = new ViewPager (nn_activity);
viewpage.Id = 9998;
viewpage.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent);
pageadapter = new TutorialSliderPagerAdapter (viewpage,ChildFragmentManager,nn_type);
viewpage.Adapter = pageadapter;
rootview.AddView (viewpage);
}
示例13: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var layout = new RelativeLayout(this);
this.AddContentView(layout, new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));
var menu = new DiscMenu(this, BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.xling));
layout.AddView(menu, 300, 300);
menu.SetMenus(new Dictionary<string, Drawable>() {
{"Add", this.Resources.GetDrawable(Resource.Drawable.add) },
{"Call", this.Resources.GetDrawable( Resource.Drawable.call) },
{"Camera", this.Resources.GetDrawable(Resource.Drawable.camara) },
{"Favorates", this.Resources.GetDrawable(Resource.Drawable.Favs) },
{"Setting", this.Resources.GetDrawable(Resource.Drawable.setting) },
{"Mail", this.Resources.GetDrawable(Resource.Drawable.mail) },
});
}
示例14: Scanning
public Scanning (RelativeLayout parentView, Activity parentActivity)
{
this.scanningView = parentActivity.LayoutInflater.Inflate (Resource.Layout.Scanning, null, false);
parentView.AddView (this.scanningView);
images [0] = this.scanningView.FindViewById<ImageView> (Resource.Id.scanning_1);
images [1] = this.scanningView.FindViewById<ImageView> (Resource.Id.scanning_2);
images [2] = this.scanningView.FindViewById<ImageView> (Resource.Id.scanning_3);
animator[0] = ValueAnimator.OfFloat(0, 360);
animator[0].SetDuration (8000);
animator[0].RepeatMode = ValueAnimatorRepeatMode.Restart;
animator[0].RepeatCount = int.MaxValue;
animator[0].Update += ((sender, e) => {
images [0].Rotation = (float)e.Animation.AnimatedValue;
});
animator[1] = ValueAnimator.OfFloat(0, 360);
animator[1].SetDuration (7500);
animator[1].SetInterpolator (AnimationUtils.LoadInterpolator(parentActivity, global::Android.Resource.Interpolator.Overshoot));
animator[1].RepeatMode = ValueAnimatorRepeatMode.Restart;
animator[1].RepeatCount = int.MaxValue;
animator[1].Update += ((sender, e) => {
images [1].Rotation = (float)e.Animation.AnimatedValue;
});
animator[2] = ValueAnimator.OfFloat(0, 360);
animator[2].SetDuration (3000);
animator[2].SetInterpolator (AnimationUtils.LoadInterpolator(parentActivity, global::Android.Resource.Interpolator.DecelerateQuint));
animator[2].RepeatMode = ValueAnimatorRepeatMode.Restart;
animator[2].RepeatCount = int.MaxValue;
animator[2].Update += ((sender, e) => {
images [2].Rotation = (float)e.Animation.AnimatedValue;
});
var windowwidth = parentActivity.WindowManager.DefaultDisplay.Width;
BitmapFactory.Options dimensions = new BitmapFactory.Options();
dimensions.InJustDecodeBounds = true;
BitmapFactory.DecodeResource(parentActivity.Resources, Resource.Drawable.scanning_1, dimensions);
this.scanningView.SetX ((windowwidth-dimensions.OutWidth)/2);
this.scanningView.SetY (dimensions.OutHeight+50);
scanningView.Visibility = ViewStates.Gone;
}
示例15: OnCreate
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
rootview = new RelativeLayout (nn_activity);
rootview.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent);
rootview.Id=TapUtil.generateViewId ();
viewpage = new ViewPager (nn_activity);
viewpage.Id = 9999;
viewpage.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent);
adapter = new RaffleDetailSliderPagerAdapter (this,viewpage,ChildFragmentManager,eventcards,initialpage);
viewpage.Adapter = adapter;
viewpage.SetOnPageChangeListener(adapter);
//viewpage.SetCurrentItem (initialpage + 1, false);
rootview.AddView (viewpage);
}