public PickerCellView(Context context, Cell cell) : base(context) { _cell = cell; SetMinimumWidth((int)context.ToPixels(50)); SetMinimumHeight((int)context.ToPixels(36)); Orientation = Orientation.Horizontal; var padding = (int)context.ToPixels(8); SetPadding((int)context.ToPixels(15), padding, padding, padding); _label = new ATextView(context); Android.Support.V4.Widget.TextViewCompat.SetTextAppearance(_label, Android.Resource.Style.TextAppearanceSmall); _label.SetWidth((int)context.ToPixels(80)); var layoutParams = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) { Gravity = GravityFlags.CenterVertical }; using (layoutParams) AddView(_label, layoutParams); EditText = new EditText(context); EditText.KeyListener = null; EditText.OnFocusChangeListener = this; //editText.SetBackgroundDrawable (null); layoutParams = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent) { Width = 0, Weight = 1, Gravity = GravityFlags.FillHorizontal | GravityFlags.Center }; using (layoutParams) AddView(EditText, layoutParams); }
public void ForceChildLayout(View child, LayoutParams layoutParams) { int childHeightSpec = ViewGroup.GetChildMeasureSpec(_heightMeasureSpec, PaddingTop + PaddingBottom, layoutParams.Height); int childWidthSpec = ViewGroup.GetChildMeasureSpec(_widthMeasureSpec, PaddingLeft + PaddingRight, layoutParams.Width); child.Measure(childWidthSpec, childHeightSpec); }
protected override void OnDraw(Canvas canvas) { base.OnDraw(canvas); var actionBar = ((Activity)Context).ActionBar; LinearLayout layout = new LinearLayout(Context); layout.Orientation = Orientation.Horizontal; layout.WeightSum = 100; TextView title = new TextView(Context); title.Text = actionBar.Title; title.TextSize = 18; Typeface font = Typeface.CreateFromAsset(Forms.Context.Assets, "BTrafcBd.ttf"); title.Typeface = font; LayoutParams textlp = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); ImageView logo = new ImageView(Context); logo.SetImageResource(Resource.Drawable.Logo); LayoutParams imglp = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); layout.AddView(title, textlp); layout.AddView(logo, imglp); actionBar.SetCustomView(layout, new ActionBar.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent)); actionBar.SetDisplayOptions(ActionBarDisplayOptions.ShowCustom, ActionBarDisplayOptions.ShowCustom); }
public LoadingView(Context context, string message) : base(context) { LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); LinearLayout layout = new LinearLayout(context); ProgressBar pBar = new ProgressBar(context); pBar.Indeterminate = true; layout.AddView(pBar); if (message != null) { TextView text = new TextView(context); text.Text = message; text.TextSize = 18; text.Gravity = GravityFlags.CenterVertical; text.SetPadding(Utils.DpToPx(4), 0, 0, 0); layout.AddView(text, new LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent)); } var lp = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); lp.AddRule(LayoutRules.CenterInParent); AddView(layout, lp); }
public override void Draw(Canvas canvas) { base.Draw(canvas); var listAdapter = Control.Adapter; int totalHeight = Control.PaddingTop + Control.PaddingBottom; int desiredWidth = MeasureSpec.MakeMeasureSpec(Control.Width, MeasureSpecMode.AtMost); for (int i = 0; i < Control.Count; i++) { Android.Views.View listItem = listAdapter.GetView(i, null, Control); if (listItem != null) { // This next line is needed before you call measure or else you won't get measured height at all. The listitem needs to be drawn first to know the height. listItem.LayoutParameters = new Android.Widget.RelativeLayout.LayoutParams(-2, -2); listItem.Measure(desiredWidth, 0); totalHeight += listItem.MeasuredHeight; } } LayoutParams param = Control.LayoutParameters; Element.HeightRequest = totalHeight + (Control.DividerHeight * (Control.Count - 1)); }
private void Init(Context context) { this.context = context; stickerViews = new List <StickerView>(); stickerParams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); addBackgroundImage(); }
protected override void OnElementChanged(VisualElementChangedEventArgs e) { LayoutParams p = (LayoutParams)child.LayoutParameters; p.Width = page.DrawerWidth; base.OnElementChanged(e); }
public override void OnResume() { base.OnResume(); taskdata = dbHelper.GetTaskInbox(); if (taskdata.Count != 0) { recyclerview_layoutmanger = new LinearLayoutManager(Activity, LinearLayoutManager.Vertical, false); recyclerview.SetLayoutManager(recyclerview_layoutmanger); recyclerview_adapter = new TaskInboxAdapter(Activity, taskdata, recyclerview, FragmentManager); recyclerview.SetAdapter(recyclerview_adapter); } else { LayoutParams lparams = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); TextView textView = new TextView(Activity); textView.LayoutParameters = lparams; textView.Text = "Oops ! You haven't assigned any task yet"; linearLayout.AddView(textView); } //if (FilterByDate_Activity.FromDateGlobal != null && FilterByDate_Activity.ToDateGlobal != null) //{ // List<TaskInboxModel> orderlist2 = dbHelper.getDataByDate(FilterByDate_Activity.FromDateGlobal, FilterByDate_Activity.ToDateGlobal); // recyclerview_layoutmanger = new LinearLayoutManager(Activity, LinearLayoutManager.Vertical, false); // recyclerview.SetLayoutManager(recyclerview_layoutmanger); // recyclerview_adapter = new TaskInboxAdapter(Activity, orderlist2, recyclerview, FragmentManager); // recyclerview.SetAdapter(recyclerview_adapter); //} }
/** Create shadow wrapper with a pinned view for a view at given position */ void createPinnedShadow(int position) { // try to recycle shadow PinnedSection pinnedShadow = mRecycleSection; mRecycleSection = null; // create new shadow, if needed if (pinnedShadow == null) { pinnedShadow = new PinnedSection(); } // request new view using recycled view, if such View pinnedView = Adapter.GetView(position, pinnedShadow.view, this); // read layout parameters LayoutParams layoutParams = (LayoutParams)pinnedView.LayoutParameters; if (layoutParams == null) // create default layout params { layoutParams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); //layoutParams = (LayoutParams) GenerateDefaultLayoutParams (); //generateDefaultLayoutParams(); layoutParams = new LayoutParams(GenerateDefaultLayoutParams()); pinnedView.LayoutParameters = layoutParams; } MeasureSpecMode heightMode = MeasureSpec.GetMode(layoutParams.Height); int heightSize = MeasureSpec.GetSize(layoutParams.Height); if (heightMode == MeasureSpecMode.Unspecified) { heightMode = MeasureSpecMode.Exactly; } int maxHeight = Height - ListPaddingTop - ListPaddingBottom; if (heightSize > maxHeight) { heightSize = maxHeight; } //--------------------------------------------- // measure & layout try{ int ws = MeasureSpec.MakeMeasureSpec(Width - ListPaddingLeft - ListPaddingRight, MeasureSpecMode.Exactly); //int hs = MeasureSpec.MakeMeasureSpec(heightSize, heightMode); int myNegInt = System.Math.Abs(heightSize) * (-1); int hs = MeasureSpec.MakeMeasureSpec(heightSize, heightMode); pinnedView.Measure(Convert.ToInt32(ws), Convert.ToInt32(hs)); } catch (Exception ex) { System.Console.WriteLine(ex.Message.ToString()); } mTranslateY = 0; pinnedView.Layout(0, 0, pinnedView.MeasuredWidth, pinnedView.MeasuredHeight); // initialize pinned shadow pinnedShadow.view = pinnedView; pinnedShadow.position = position; pinnedShadow.id = Adapter.GetItemId(position); // store pinned shadow mPinnedSection = pinnedShadow; }
public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) { var selector = _listView.ItemTemplate as DataTemplateSelector; var template = _templateTypeID.FirstOrDefault(e => e.Value == viewType).Key; var viewCell = template.CreateContent() as ViewCell; if (Platform.GetRenderer(viewCell.View) == null) { Platform.SetRenderer(viewCell.View, Platform.CreateRendererWithContext(viewCell.View, parent.Context)); } var renderer = Platform.GetRenderer(viewCell.View); viewCell.Parent = _listView; var metrics = parent.Context.Resources.DisplayMetrics; var width = (int)(_listView.ItemWidth * metrics.Density); var height = (int)(_listView.ItemHeight * metrics.Density); viewCell.View.Layout(new Rectangle(0, 0, _listView.ItemWidth, _listView.ItemHeight)); var layoutParams = new LayoutParams(width, height); var viewGroup = renderer.View; viewGroup.LayoutParameters = layoutParams; return(new RecyclerViewHolder(viewCell, viewGroup)); }
public override View OnCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) { View view = layoutInflater.Inflate(Resource.Layout.fragment_onechoice_questionario, viewGroup, false); TextView textView = view.FindViewById <TextView>(Resource.Id.title_text_view); RadioGroup radioGroup = view.FindViewById <RadioGroup>(Resource.Id.options_group); LinearLayout linearLayout = view.FindViewById <LinearLayout>(Resource.Id.options_layout); textView.Text = _questao.getTitulo(); textView.Selected = true; int respostaSelected = QuestionarioManager.GetInstance().LastRespostaSelected(_page); List <Resposta> respostas = _questao.Respostas; for (int i = 0; i < _questao.Respostas.Count; i++) { int id = i; QuestionarioWidgetGenerator.CreateRadioButton(radioGroup, _page, id, respostas[i].Descricao, respostaSelected == id); } LinearLayout layout = view.FindViewById <LinearLayout>(Resource.Id.root_options_layout); EditNewRespostaLayout editNewRespostaLayout = new EditNewRespostaLayout(view.Context); LayoutParams lparams = new LayoutParams(-1, -2); lparams.SetMargins(14, 0, 0, 0); layout.AddView(editNewRespostaLayout, lparams); return(view); }
protected void AddContentView (ViewGroup container, View quizContentView) { var layoutParams = new LayoutParams (ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); container.AddView (questionView, layoutParams); container.AddView (quizContentView, layoutParams); AddView (container, layoutParams); }
internal LegendItemView(Context context) : base(context) { Orientation = Orientation.Vertical; LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); SetGravity(GravityFlags.Top); _textView = new TextView(context) { LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent) }; AddView(_textView); _layerLegend = new LayerLegend(context) { LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent), ShowEntireTreeHierarchy = false }; AddView(_layerLegend); _listView = new ListView(context) { LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent), ScrollingCacheEnabled = false, PersistentDrawingCache = PersistentDrawingCaches.NoCache, }; AddView(_listView); RequestLayout(); }
private PwEntryView(GroupBaseActivity groupActivity, PwEntry pw, int pos) : base(groupActivity) { _groupActivity = groupActivity; View ev = Inflate(groupActivity, Resource.Layout.entry_list_entry, null); _textView = (TextView)ev.FindViewById(Resource.Id.entry_text); _textView.TextSize = PrefsUtil.GetListTextSize(groupActivity); ev.FindViewById(Resource.Id.entry_icon_bkg).Visibility = App.Kp2a.GetDb().DrawableFactory.IsWhiteIconSet ? ViewStates.Visible : ViewStates.Gone; _textviewDetails = (TextView)ev.FindViewById(Resource.Id.entry_text_detail); _textviewDetails.TextSize = PrefsUtil.GetListDetailTextSize(groupActivity); _textgroupFullPath = (TextView)ev.FindViewById(Resource.Id.group_detail); _textgroupFullPath.TextSize = PrefsUtil.GetListDetailTextSize(groupActivity); _showDetail = PreferenceManager.GetDefaultSharedPreferences(groupActivity).GetBoolean( groupActivity.GetString(Resource.String.ShowUsernameInList_key), Resources.GetBoolean(Resource.Boolean.ShowUsernameInList_default)); _showGroupFullPath = PreferenceManager.GetDefaultSharedPreferences(groupActivity).GetBoolean( groupActivity.GetString(Resource.String.ShowGroupnameInSearchResult_key), Resources.GetBoolean(Resource.Boolean.ShowGroupnameInSearchResult_default)); _isSearchResult = _groupActivity is keepass2android.search.SearchResults; PopulateView(ev, pw, pos); LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); AddView(ev, lp); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (plInviteFriendSettings.Visible) { if (siteActivityRule != null) { var inviteFriendComponent = siteActivityRule.tbl_SiteActivityRuleLayout.FirstOrDefault(o => o.LayoutType == (int)LayoutType.InviteFriend); if (inviteFriendComponent != null && !string.IsNullOrEmpty(inviteFriendComponent.LayoutParams)) { var lp = LayoutParams.Deserialize(inviteFriendComponent.LayoutParams); if (!string.IsNullOrEmpty(lp.GetValue("SiteActionTemplateID"))) { ucPopupSiteActionTemplate.UpdateUI(DataManager.SiteActionTemplate.SelectById(Guid.Parse(lp.GetValue("SiteActionTemplateID")))); } } } else { var siteActionTemplate = DataManager.SiteActionTemplate.SelectById(ucPopupSiteActionTemplate.SiteActionTemplateId); ucPopupSiteActionTemplate.UpdateUI(siteActionTemplate); } } }
protected override bool AddViewInLayout(View child, int index, LayoutParams @params, bool preventRequestLayout) { if (ChildCount > 1) throw new InvalidOperationException("FoldingLayout can only have 1 child at most"); return base.AddViewInLayout(child, index, @params, preventRequestLayout); }
private void addIndicator(Android.Widget.Orientation orientation, int backgroundDrawableId, Animator animator) { if (animator.IsRunning) { animator.End(); animator.Cancel(); } var indicator = new View(Context); indicator.SetBackgroundResource(backgroundDrawableId); AddView(indicator, mIndicatorWidth, mIndicatorHeight); LayoutParams lp = (LayoutParams)indicator.LayoutParameters; if (orientation == Android.Widget.Orientation.Horizontal) { lp.LeftMargin = mIndicatorMargin; lp.RightMargin = mIndicatorMargin; } else { lp.TopMargin = mIndicatorMargin; lp.BottomMargin = mIndicatorMargin; } indicator.LayoutParameters = lp; animator.SetTarget(indicator); animator.Start(); }
internal LegendItemView(Context context) : base(context) { Orientation = Orientation.Vertical; LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); SetGravity(GravityFlags.Top); _textView = new TextView(context) { LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent) }; AddView(_textView); _layerLegend = new LayerLegend(context) { LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent), IncludeSublayers = false }; AddView(_layerLegend); _listView = new ListView(context) { ClipToOutline = true, Clickable = false, ChoiceMode = ChoiceMode.None, LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent), ScrollingCacheEnabled = false, PersistentDrawingCache = PersistentDrawingCaches.NoCache, }; AddView(_listView); RequestLayout(); }
public CardboardOverlayView(Context context, AttributeSet attrs) : base(context, attrs) { setOrientation(HORIZONTAL); LayoutParams @params = new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f); @params.setMargins(0, 0, 0, 0); leftView = new CardboardOverlayEyeView(context, attrs); leftView.setLayoutParams(@params); addView(leftView); rightView = new CardboardOverlayEyeView(context, attrs); rightView.setLayoutParams(@params); addView(rightView); // Set some reasonable defaults. setDepthOffset(0.016f); setColor(Color.rgb(150, 255, 180)); setVisibility(View.VISIBLE); textFadeAnimation = new AlphaAnimation(1.0f, 0.0f); textFadeAnimation.setDuration(5000); }
public override void AddView(Android.Views.View child, int index, LayoutParams @params) { if (ChildCount == 0) { ((CalendarRowView) child).IsHeaderRow = true; } base.AddView(child, index, @params); }
private PwGroupView(GroupBaseActivity act, PwGroup pw) : base(act) { _groupBaseActivity = act; View gv = Inflate(act, Resource.Layout.group_list_entry, null); _textview = (TextView)gv.FindViewById(Resource.Id.group_text); float size = PrefsUtil.GetListTextSize(act); _textview.TextSize = size; _label = (TextView)gv.FindViewById(Resource.Id.group_label); _label.TextSize = size - 8; Database db = App.Kp2a.FindDatabaseForElement(pw); gv.FindViewById(Resource.Id.group_icon_bkg).Visibility = db.DrawableFactory.IsWhiteIconSet ? ViewStates.Visible : ViewStates.Gone; gv.FindViewById(Resource.Id.icon).Visibility = ViewStates.Visible; gv.FindViewById(Resource.Id.check_mark).Visibility = ViewStates.Invisible; PopulateView(gv, pw); LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent); AddView(gv, lp); }
public override void SetAnchorView(View view) { base.SetAnchorView(view); ibFullScreen = new ImageButton(Context); ibFullScreen.SetBackgroundColor(Color.Transparent); int layoutPx = DiPtoPx(40, view.Context); int topMarginPx = DiPtoPx(10, view.Context); int leftMarginPx = DiPtoPx(5, view.Context); LayoutParams layoutParams = new LayoutParams(layoutPx, layoutPx, GravityFlags.NoGravity) { TopMargin = topMarginPx, LeftMargin = leftMarginPx, }; int imageId = IsFullScreen() ? fullScreenExitImageId : fullScreenImageId; ibFullScreen.SetImageResource(imageId); ibFullScreen.ScaleX = 0.5f; ibFullScreen.ScaleY = 0.5f; AddView(ibFullScreen, layoutParams); ibFullScreen.SetOnClickListener(new OnClickListener()); layoutParams = new LayoutParams(DiPtoPx(56, view.Context), DiPtoPx(16, view.Context), GravityFlags.Right) { TopMargin = DiPtoPx(5, view.Context), RightMargin = DiPtoPx(5, view.Context), }; tvVideoSize = new TextView(Context); tvVideoSize.SetBackgroundColor(Color.Transparent); tvVideoSize.SetTextColor(Color.White); tvVideoSize.SetTextSize(ComplexUnitType.Pt, 6); tvVideoSize.Gravity = GravityFlags.Right; AddView(tvVideoSize, layoutParams); }
public LayoutParams(LayoutParams source) : base(source) { IsDraggableTopDirection = source.IsDraggableTopDirection; IsDraggableBottomDirection = source.IsDraggableBottomDirection; IsDraggableLeftDirection = source.IsDraggableLeftDirection; IsDraggableRightDirection = source.IsDraggableRightDirection; }
private void InitImageIcon() { if (!_hasIcon) { return; } ImageView icon = new ImageView(Context); var lParams = new LayoutParams((int)Resources.GetDimension(Resource.Dimension.chip_height), (int)Resources.GetDimension(Resource.Dimension.chip_height)); lParams.AddRule(Build.VERSION.SdkInt >= BuildVersionCodes.JellyBeanMr1 ? LayoutRules.AlignParentStart : LayoutRules.AlignParentLeft); icon.LayoutParameters = lParams; icon.SetScaleType(ImageView.ScaleType.FitCenter); icon.Id = ChipUtils.IMAGE_ID; if (_chipIcon != null) { if (_chipIcon is BitmapDrawable bitmapDrawable && bitmapDrawable.Bitmap != null) { Bitmap bitmap = ((BitmapDrawable)_chipIcon).Bitmap; bitmap = ChipUtils.GetSquareBitmap(bitmap); bitmap = ChipUtils.GetScaledBitmap(Context, bitmap); icon.SetImageBitmap(ChipUtils.GetCircleBitmap(Context, bitmap)); } else { icon.SetImageDrawable(_chipIcon); } }
public void Init(Context context, IAttributeSet attrs) { try { //Setup image attributes MImgSource = new FilterImageView(context); MImgSource.Id = ImgSrcId; MImgSource.SetAdjustViewBounds(true); LayoutParams imgSrcParam = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); imgSrcParam.AddRule(LayoutRules.CenterInParent, ImgSrcId); if (attrs != null) { //TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.NiceArtEditorView); //Drawable imgSrcDrawable = a.GetDrawable(Resource.Styleable.NiceArtEditorView_photo_src); //if (imgSrcDrawable != null) //{ // MImgSource.SetImageDrawable(imgSrcDrawable); //} } //Setup brush view MBrushDrawingView = new BrushDrawingView(context); MBrushDrawingView.Visibility = ViewStates.Gone; MBrushDrawingView.Id = BrushSrcId; //Align brush to the size of image view LayoutParams brushParam = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); brushParam.AddRule(LayoutRules.CenterInParent, ImgSrcId); brushParam.AddRule(LayoutRules.AlignTop, ImgSrcId); brushParam.AddRule(LayoutRules.AlignBottom, ImgSrcId); //Setup GLSurface attributes MImageFilterView = new ImageFilterView(context) { Id = GlFilterId, Visibility = ViewStates.Gone }; //Align brush to the size of image view LayoutParams imgFilterParam = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); imgFilterParam.AddRule(LayoutRules.CenterInParent, ImgSrcId); imgFilterParam.AddRule(LayoutRules.AlignTop, ImgSrcId); imgFilterParam.AddRule(LayoutRules.AlignBottom, ImgSrcId); OnBitmapLoaded(MImgSource.GetBitmap()); //Add image source AddView(MImgSource, imgSrcParam); //Add Gl FilterView AddView(MImageFilterView, imgFilterParam); //Add brush view AddView(MBrushDrawingView, brushParam); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public PostingDetailsView(Context context) : base(context) { _context = context; rowParams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); Initialize(); }
public override void AddView(View child, LayoutParams @params) { if (ChildCount > 1) throw new InvalidOperationException ("PictureLayout can only host one direct child."); base.AddView (child, @params); }
protected override void OnElementChanged(ElementChangedEventArgs <Page> e) { base.OnElementChanged(e); var actionBar = ((Activity)Context).ActionBar; LinearLayout layout = new LinearLayout(Context); layout.Orientation = Orientation.Horizontal; layout.WeightSum = Width; layout.SetGravity(GravityFlags.Left); TextView title = new TextView(Context); title.Text = actionBar.Title; title.TextSize = 18; Typeface font = Typeface.CreateFromAsset(Forms.Context.Assets, "BTrafcBd.ttf"); title.Typeface = font; LayoutParams textlp = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); ImageView logo = new ImageView(Context); logo.Clickable = true; logo.Click += Logo_Click; logo.SetImageResource(Resource.Drawable.Logo); logo.SetScaleType(ImageView.ScaleType.FitStart); layout.AddView(logo); actionBar.SetCustomView(layout, new ActionBar.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent)); actionBar.SetDisplayOptions(ActionBarDisplayOptions.ShowCustom, ActionBarDisplayOptions.ShowCustom); }
public ClipImageView(Context context, IAttributeSet attrs) : base(context, attrs) { this.Background = new ColorDrawable(Color.White); _contentView = new ClipImageContentView(context); _borderView = new ClipImageBorderView(context); var lp = new LayoutParams( Android.Views.ViewGroup.LayoutParams.MatchParent, Android.Views.ViewGroup.LayoutParams.MatchParent); this.AddView(_contentView, lp); this.AddView(_borderView, lp); //lp=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); //lp.AddRule(LayoutRules.AlignParentRight); //Button clipButton = new Button(this.Context); //clipButton.Click += ClipButton_Click; // 计算padding的px mHorizontalPadding = (int)TypedValue.ApplyDimension( ComplexUnitType.Dip, mHorizontalPadding, Resources.DisplayMetrics); _contentView.setHorizontalPadding(mHorizontalPadding); _borderView.setHorizontalPadding(mHorizontalPadding); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); /* * int screenWidth = Resources.DisplayMetrics.WidthPixels; * int screenHeight = Resources.DisplayMetrics.HeightPixels; * * // say 10 cards on a screen horizontally * int cardWidth = screenWidth / 10; * int cardHeight = (int)(726.0 / 500.0 * cardWidth); * * ImageView view = (ImageView)FindViewById(Resource.Id.imageView1); * LayoutParams viewParams = view.LayoutParameters; * viewParams.Width = cardWidth; * viewParams.Height = cardHeight; * * view.SetImageResource(Resource.Drawable.aceOfClubs); */ /* * ImageView view = (ImageView)FindViewById(Resource.Id.imageView1); * LayoutParams viewParams = view.LayoutParameters; */ HandView view = (HandView)FindViewById(Resource.Id.handView1); LayoutParams viewParams = view.LayoutParameters; System.Diagnostics.Debug.WriteLine(viewParams.Width); System.Diagnostics.Debug.WriteLine(viewParams.Height); Button startGame = FindViewById <Button>(Resource.Id.button1); startGame.Click += StartGame_Click; }
private ViewGroup CreateVideoView(SurfaceView surface) { try { RelativeLayout layout = new RelativeLayout(Context) { Id = surface.GetHashCode() }; LayoutParams videoLayoutParams = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); layout.AddView(surface, videoLayoutParams); TextView text = new TextView(Context) { Id = layout.GetHashCode() }; LayoutParams textParams = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); textParams.AddRule(LayoutRules.AlignParentBottom, 1); textParams.BottomMargin = MStatMarginBottom; textParams.LeftMargin = StatLeftMargin; text.SetTextColor(Color.White); text.SetTextSize(ComplexUnitType.Sp, StatTextSize); layout.AddView(text, textParams); return(layout); } catch (Exception e) { Methods.DisplayReportResultTrack(e); return(null); } }
public BaseCellView(Context context, Cell cell) : base(context) { _cell = cell; SetMinimumWidth((int)context.ToPixels(25)); SetMinimumHeight((int)context.ToPixels(25)); Orientation = Orientation.Horizontal; var padding = (int)context.FromPixels(8); SetPadding(padding, padding, padding, padding); _imageView = new ImageView(context); var imageParams = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent) { Width = (int)context.ToPixels(60), Height = (int)context.ToPixels(60), RightMargin = 0, Gravity = GravityFlags.Center }; using (imageParams) AddView(_imageView, imageParams); var textLayout = new LinearLayout(context) { Orientation = Orientation.Vertical }; _mainText = new TextView(context); _mainText.SetSingleLine(true); _mainText.Ellipsize = TextUtils.TruncateAt.End; _mainText.SetPadding((int)context.ToPixels(15), padding, padding, padding); TextViewCompat.SetTextAppearance(_mainText, global::Android.Resource.Style.TextAppearanceSmall); using (var lp = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent)) textLayout.AddView(_mainText, lp); _detailText = new TextView(context); _detailText.SetSingleLine(true); _detailText.Ellipsize = TextUtils.TruncateAt.End; _detailText.SetPadding((int)context.ToPixels(15), padding, padding, padding); _detailText.Visibility = ViewStates.Gone; TextViewCompat.SetTextAppearance(_detailText, global::Android.Resource.Style.TextAppearanceSmall); using (var lp = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent)) textLayout.AddView(_detailText, lp); var layoutParams = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent) { Width = 0, Weight = 1, Gravity = GravityFlags.Center }; using (layoutParams) AddView(textLayout, layoutParams); SetMinimumHeight((int)context.ToPixels(DefaultMinHeight)); _androidDefaultTextColor = Color.FromUint((uint)_mainText.CurrentTextColor); _mainText.TextAlignment = global::Android.Views.TextAlignment.ViewStart; _detailText.TextAlignment = global::Android.Views.TextAlignment.ViewStart; }
internal LegendItemView(Context context) : base(context) { Orientation = Orientation.Horizontal; LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); SetGravity(GravityFlags.Top); _textView = new TextView(context) { LayoutParameters = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent) { Gravity = GravityFlags.CenterVertical | GravityFlags.Left } }; var maxSize = (int)(Resources.DisplayMetrics.Density * 40); _symbol = new SymbolDisplay(context) { LayoutParameters = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent) { Gravity = GravityFlags.Center, Width = maxSize } }; _symbol.SetMaxHeight(maxSize); _symbol.SetMaxWidth(maxSize); AddView(_symbol); AddView(_textView); RequestLayout(); }
public override void AddView(AView child, int index, LayoutParams @params) { if (index == -1 && AddFlag && child.GetType().ToString() == sPageContainer) { index = ChildCount - 1; } base.AddView(child, index, @params); if (child is AToolbar) { Toolbar = child as AToolbar; } else if (child.GetType().ToString() == sPageContainer) { PageContainer = child as ViewGroup; var layoutParam = new LayoutParams(LayoutParams.MatchParent, 8); if (!AddFlag) { AddView(ProgressBar, layoutParam); } } else if (child is AProgressBar) { AddFlag = true; } }
public FileStorageViewKp2a(Activity activity) : base(activity) { View ev = Inflate(activity, Resource.Layout.filestorage_selection_listitem_kp2a, null); LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent); AddView(ev, lp); }
protected void AddFloatingActionButton () { var fabSize = Resources.GetDimensionPixelSize (Resource.Dimension.size_fab); var bottomOfQuestionView = FindViewById (Resource.Id.question_view).Bottom; var fabLayoutParams = new LayoutParams (fabSize, fabSize, GravityFlags.End | GravityFlags.Top); var halfAFab = fabSize / 2; fabLayoutParams.SetMargins (0, // left bottomOfQuestionView - halfAFab, //top 0, // right spacingDouble); // bottom fabLayoutParams.MarginEnd = spacingDouble; AddView (submitAnswer, fabLayoutParams); }
public FileStorageView(Activity activity, string protocolId, int pos) : base(activity) { View ev = Inflate(activity, Resource.Layout.filestorage_selection_listitem, null); _textView = (TextView)ev.FindViewById(Resource.Id.filestorage_label); _textView.TextSize = PrefsUtil.GetListTextSize(activity); PopulateView(ev, protocolId, pos); LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent); AddView(ev, lp); }
public MapViewLayoutParams(LayoutParams source) : base(source) { var lp = source as MapViewLayoutParams; if (lp != null) { this.X = lp.X; this.Y = lp.Y; this.Point = lp.Point; this.Mode = lp.Mode; this.Alignment = lp.Alignment; } }
public BaseCellView(Context context, Cell cell) : base(context) { _cell = cell; SetMinimumWidth((int)context.ToPixels(25)); SetMinimumHeight((int)context.ToPixels(25)); Orientation = Orientation.Horizontal; var padding = (int)context.FromPixels(8); SetPadding(padding, padding, padding, padding); _imageView = new ImageView(context); var imageParams = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent) { Width = (int)context.ToPixels(60), Height = (int)context.ToPixels(60), RightMargin = 0, Gravity = GravityFlags.Center }; using (imageParams) AddView(_imageView, imageParams); var textLayout = new LinearLayout(context) { Orientation = Orientation.Vertical }; _mainText = new TextView(context); _mainText.SetSingleLine(true); _mainText.Ellipsize = TextUtils.TruncateAt.End; _mainText.SetPadding((int)context.ToPixels(15), padding, padding, padding); _mainText.SetTextAppearanceCompat(context, global::Android.Resource.Style.TextAppearanceSmall); using (var lp = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent)) textLayout.AddView(_mainText, lp); _detailText = new TextView(context); _detailText.SetSingleLine(true); _detailText.Ellipsize = TextUtils.TruncateAt.End; _detailText.SetPadding((int)context.ToPixels(15), padding, padding, padding); _detailText.Visibility = ViewStates.Gone; _detailText.SetTextAppearanceCompat(context, global::Android.Resource.Style.TextAppearanceSmall); using (var lp = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent)) textLayout.AddView(_detailText, lp); var layoutParams = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent) { Width = 0, Weight = 1, Gravity = GravityFlags.Center }; using (layoutParams) AddView(textLayout, layoutParams); SetMinimumHeight((int)context.ToPixels(DefaultMinHeight)); _androidDefaultTextColor = Color.FromUint((uint)_mainText.CurrentTextColor); }
protected override void OnFinishInflate() { base.OnFinishInflate(); View view = LayoutInflater.From(Context).Inflate(Resource.Layout.LoadView, null); mDistance = Dip2Px(54f); LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); layoutParams.Gravity = GravityFlags.Center; shapeLoadingView = view.FindViewById<ShapeLoadingView>(Resource.Id.shapeLoadingView); indicationIm = view.FindViewById<ImageView>(Resource.Id.indication); loadTextView = view.FindViewById<TextView>(Resource.Id.promptTV); SetLoadingText(loadText); AddView(view, layoutParams); this.PostDelayed(() => { FreeFall(); }, 900); }
private void Initialize() { ImageView logo = new ImageView(Context) { Id = 0x0fffff2a }; logo.SetImageResource(Resource.Drawable.logo); logo.SetAdjustViewBounds(true); logo.SetMinimumHeight(60); logo.SetMaxHeight(60); _imageCategoryView = new ImageView(Context); _imageCategoryView.SetAdjustViewBounds(true); _imageCategoryView.SetMinimumHeight(60); _imageCategoryView.SetMaxHeight(60); _imageCategoryView.Id = 0x0fffff2b; _imageCategoryView.SetMinimumWidth(60); _imageCategoryView.SetMaxWidth(60); _imageCategoryView.Measure(60, 60); _textCategoryView = new TextView(Context); _textCategoryView.SetMaxHeight(60); _textCategoryView.SetTextColor(Color.Black); _textCategoryView.Id = 0x0fffff2c; _textCategoryView.SetTextSize(ComplexUnitType.Sp, 15); _textCategoryView.Gravity = GravityFlags.CenterVertical; LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); lp.AddRule(LayoutRules.AlignParentRight); lp.AddRule(LayoutRules.CenterVertical); AddView(logo, lp); lp = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); lp.AddRule(LayoutRules.AlignParentLeft); lp.AddRule(LayoutRules.CenterVertical); AddView(_imageCategoryView, lp); lp = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); lp.AddRule(LayoutRules.RightOf, _imageCategoryView.Id); lp.AddRule(LayoutRules.CenterVertical); lp.SetMargins(60, 0, 60, 0); AddView(_textCategoryView, lp); }
public void AddViewInLayoutOverride(View view) { this.AddViewInLayout(view, -1, layoutParams ?? (layoutParams = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent)), true); }
public void SetRenderHeight(double height) { height = Context.ToPixels(height); LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.MatchParent, (int)(height == -1 ? ViewGroup.LayoutParams.WrapContent : height)); }
private void Initialize() { Id = _viewId; _maxNumberOfIndiagrams = LazyResolver<IScreenService>.Service.Width / IndiagramView.DefaultWidth - 1; ISettingsService settings = LazyResolver<ISettingsService>.Service; ColorStringToIntConverter colorConverter = new ColorStringToIntConverter(); // Init views for (int i = 0; i < _maxNumberOfIndiagrams; ++i) { IndiagramView view = new IndiagramView(Context) { TextColor = (uint) colorConverter.Convert(settings.TextColor, null, null, null), Id = _viewId++, DefaultColor = 0, }; view.Touch += OnIndiagramTouched; var layoutParams = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); layoutParams.AddRule(LayoutRules.CenterVertical); if (i == 0) { layoutParams.AddRule(LayoutRules.AlignParentLeft); } else { layoutParams.AddRule(LayoutRules.RightOf, _viewId - 2); } AddView(view, layoutParams); _indiagramViews.Add(view); } // Init play button _playButton = new IndiagramView(Context) { TextColor = 0, Id = _viewId++, Indiagram = new Indiagram() { Text = "play", ImagePath = LazyResolver<IStorageService>.Service.ImagePlayButtonPath } }; _playButton.Touch += (sender, args) => { if (args.Event.ActionMasked == MotionEventActions.Up){ if(args.Event.RawX<(LazyResolver<IScreenService>.Service.Width/4.0)){ if (CorrectionCommand != null && CorrectionCommand.CanExecute(null)) { CorrectionCommand.Execute(null); } } else if (ReadCommand != null && ReadCommand.CanExecute(null)) { ReadCommand.Execute(null); } } }; var lp = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); lp.AddRule(LayoutRules.AlignParentRight); lp.AddRule(LayoutRules.CenterVertical); AddView(_playButton, lp); }
private PwEntryView(GroupBaseActivity groupActivity, PwEntry pw, int pos) : base(groupActivity) { _groupActivity = groupActivity; View ev = Inflate(groupActivity, Resource.Layout.entry_list_entry, null); _textView = (TextView)ev.FindViewById(Resource.Id.entry_text); _textView.TextSize = PrefsUtil.GetListTextSize(groupActivity); _textviewDetails = (TextView)ev.FindViewById(Resource.Id.entry_text_detail); _textviewDetails.TextSize = PrefsUtil.GetListDetailTextSize(groupActivity); _textgroupFullPath = (TextView)ev.FindViewById(Resource.Id.group_detail); _textgroupFullPath.TextSize = PrefsUtil.GetListDetailTextSize(groupActivity); _showDetail = PreferenceManager.GetDefaultSharedPreferences(groupActivity).GetBoolean( groupActivity.GetString(Resource.String.ShowUsernameInList_key), Resources.GetBoolean(Resource.Boolean.ShowUsernameInList_default)); _showGroupFullPath = PreferenceManager.GetDefaultSharedPreferences(groupActivity).GetBoolean( groupActivity.GetString(Resource.String.ShowGroupnameInSearchResult_key), Resources.GetBoolean(Resource.Boolean.ShowGroupnameInSearchResult_default)); _isSearchResult = _groupActivity is keepass2android.search.SearchResults; PopulateView(ev, pw, pos); LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent); AddView(ev, lp); }
public override void AddView(Android.Views.View child, int index, LayoutParams @params) { child.SetOnClickListener(this); base.AddView(child, index, @params); }
public SlidingMenu(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle) { var behindParams = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); _viewBehind = new CustomViewBehind(context); AddView(_viewBehind, behindParams); var aboveParams = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); _viewAbove = new CustomViewAbove(context); AddView(_viewAbove, aboveParams); _viewAbove.CustomViewBehind = _viewBehind; _viewBehind.CustomViewAbove = _viewAbove; _viewAbove.PageSelected += (sender, args) => { if (args.Position == 0 && null != Open) //position open Open(this, EventArgs.Empty); else if (args.Position == 2 && null != Close) //position close Close(this, EventArgs.Empty); }; _viewAbove.Opened += (sender, args) => { if (null != Opened) Opened(sender, args); }; _viewAbove.Closed += (sender, args) => { if (null != Closed) Closed(sender, args); }; _viewAbove.PageScrolled += (sender, args) => { if (null != PageScrolled) PageScrolled (sender, args); }; var a = context.ObtainStyledAttributes(attrs, Resource.Styleable.SlidingMenu); var mode = a.GetInt(Resource.Styleable.SlidingMenu_mode, (int) MenuMode.Left); Mode = (MenuMode) mode; var viewAbove = a.GetResourceId(Resource.Styleable.SlidingMenu_viewAbove, -1); if (viewAbove != -1) SetContent(viewAbove); else SetContent(new FrameLayout(context)); TouchModeAbove = (TouchMode)a.GetInt(Resource.Styleable.SlidingMenu_touchModeAbove, (int)TouchMode.Margin); TouchModeBehind = (TouchMode)a.GetInt(Resource.Styleable.SlidingMenu_touchModeBehind, (int)TouchMode.Margin); var offsetBehind = (int) a.GetDimension(Resource.Styleable.SlidingMenu_behindOffset, -1); var widthBehind = (int) a.GetDimension(Resource.Styleable.SlidingMenu_behindWidth, -1); if (offsetBehind != -1 && widthBehind != -1) throw new ArgumentException("Cannot set both behindOffset and behindWidth for SlidingMenu, check your XML"); if (offsetBehind != -1) BehindOffset = offsetBehind; else if (widthBehind != -1) BehindWidth = widthBehind; else BehindOffset = 0; var shadowRes = a.GetResourceId(Resource.Styleable.SlidingMenu_shadowDrawable, -1); if (shadowRes != -1) ShadowDrawableRes = shadowRes; BehindScrollScale = a.GetFloat(Resource.Styleable.SlidingMenu_behindScrollScale, 0.33f); ShadowWidth = ((int)a.GetDimension(Resource.Styleable.SlidingMenu_shadowWidth, 0)); FadeEnabled = a.GetBoolean(Resource.Styleable.SlidingMenu_fadeEnabled, true); FadeDegree = a.GetFloat(Resource.Styleable.SlidingMenu_fadeDegree, 0.33f); SelectorEnabled = a.GetBoolean(Resource.Styleable.SlidingMenu_selectorEnabled, false); var selectorRes = a.GetResourceId(Resource.Styleable.SlidingMenu_selectorDrawable, -1); if (selectorRes != -1) SelectorDrawable = selectorRes; a.Recycle(); }
protected override void OnElementChanged(ElementChangedEventArgs<Page> e) { base.OnElementChanged(e); var actionBar = ((Activity)Context).ActionBar; LinearLayout layout = new LinearLayout(Context); layout.Orientation = Orientation.Horizontal; layout.WeightSum = Width; layout.SetGravity(GravityFlags.Left); TextView title = new TextView(Context); title.Text = actionBar.Title; title.TextSize = 18; Typeface font = Typeface.CreateFromAsset(Forms.Context.Assets, "BTrafcBd.ttf"); title.Typeface = font; LayoutParams textlp = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); ImageView logo = new ImageView(Context); logo.Clickable = true; logo.Click += Logo_Click; logo.SetImageResource(Resource.Drawable.Logo); logo.SetScaleType(ImageView.ScaleType.FitStart); layout.AddView(logo); actionBar.SetCustomView(layout, new ActionBar.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent)); actionBar.SetDisplayOptions(ActionBarDisplayOptions.ShowCustom, ActionBarDisplayOptions.ShowCustom); }
private void Initialize() { _reinforcerView = new View(Context); LayoutParams param = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); param.AddRule(LayoutRules.CenterInParent); AddView(_reinforcerView, param); _indiagramView = new ImageView(Context); param = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); param.AddRule(LayoutRules.CenterInParent); AddView(_indiagramView, param); _indiagramView.SetImageResource(Resource.Drawable.root); }
private int GetHorizontalSpacing(LayoutParams lp) { int hSpacing; if (lp.HorizontalSpacingSpecified()) { hSpacing = lp.HorizontalSpacing; } else { hSpacing = HorizontalSpacing; } return hSpacing; }
private int GetVerticalSpacing(LayoutParams lp) { int vSpacing; if (lp.VerticalSpacingSpecified()) { vSpacing = lp.VerticalSpacing; } else { vSpacing = VerticalSpacing; } return vSpacing; }
/** * ��ʼ������ */ private void initHeaderViewAndFooterViewAndListView(Context context) { this.Orientation = Orientation.Vertical; //setDrawingCacheEnabled(false); /* * �Զ���ͷ���ļ� * ������������Ϊ���ǵ��ܶ���涼��Ҫʹ�� * ���Ҫ�ģ�������ص����ö�Ҫ���� */ mHeaderView = LayoutInflater.From(context).Inflate(Resource.Layout.pulldown_header, null); mHeaderViewParams = new LayoutParams(LayoutParams.FillParent, LayoutParams.WrapContent); this.AddView(mHeaderView, 0, mHeaderViewParams); mHeaderTextView = (TextView)mHeaderView.FindViewById<TextView>(Resource.Id.pulldown_header_text); mHeaderArrowView = (ImageView)mHeaderView.FindViewById<ImageView>(Resource.Id.pulldown_header_arrow); mHeaderLoadingView = mHeaderView.FindViewById(Resource.Id.pulldown_header_loading); // ע�⣬ͼƬ��ת֮����ִ����ת����������¿�ʼ���� mRotateOTo180Animation = new RotateAnimation(0, 180, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); mRotateOTo180Animation.Duration = 250; mRotateOTo180Animation.FillAfter = true; mRotate180To0Animation = new RotateAnimation(0, 180, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); mRotate180To0Animation.Duration = 250; mRotate180To0Animation.FillAfter = true; /** * �Զ���Ų��ļ� */ mFooterView = LayoutInflater.From(context).Inflate(Resource.Layout.pulldown_footer, null); mFooterTextView = (TextView)mFooterView.FindViewById(Resource.Id.pulldown_footer_text); mFooterLoadingView = mFooterView.FindViewById(Resource.Id.pulldown_footer_loading); //mFooterView.SetOnClickListener(IOnClickListenerDelegate); mFooterView.Click += new EventHandler(mFooterView_Click); mListView = new ScrollOverListView(context); mListView.setOnScrollOverListener(this); mListView.CacheColorHint = Android.Graphics.Color.Argb(0, 0, 0, 0); AddView(mListView, LayoutParams.FillParent, LayoutParams.FillParent); mOnPullDownListener = new PullDownListener(); }
public LayoutParams(LayoutParams layoutParams) /* MethodBuilder.Create */ { }
/** * Instantiates a new SlidingMenu. * * @param context the associated Context * @param attrs the attrs * @param defStyle the def style */ public SlidingMenu(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle) { LayoutParams behindParams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); mViewBehind = new CustomViewBehind(context); AddView(mViewBehind, behindParams); LayoutParams aboveParams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); mViewAbove = new CustomViewAbove(context); AddView(mViewAbove, aboveParams); // register the CustomViewBehind with the CustomViewAbove mViewAbove.setCustomViewBehind(mViewBehind); mViewBehind.setCustomViewAbove(mViewAbove); mViewAbove.setOnPageChangeListener(new PageChangeClass(mOpenListener, mCloseListener, mSecondaryOpenListner)); //mViewAbove.setOnPageChangeListener(new OnPageChangeListener() { // public static readonly int POSITION_OPEN = 0; // public static readonly int POSITION_CLOSE = 1; // public static readonly int POSITION_SECONDARY_OPEN = 2; // public void onPageScrolled(int position, float positionOffset, // int positionOffsetPixels) { } // public void onPageSelected(int position) { // if (position == POSITION_OPEN && mOpenListener != null) { // mOpenListener.onOpen(); // } else if (position == POSITION_CLOSE && mCloseListener != null) { // mCloseListener.onClose(); // } else if (position == POSITION_SECONDARY_OPEN && mSecondaryOpenListner != null ) { // mSecondaryOpenListner.onOpen(); // } // } //}); // now style everything! TypedArray ta = context.ObtainStyledAttributes(attrs, Resource.Styleable.SlidingMenu); // set the above and behind views if defined in xml SlidingMenuMode mode = (SlidingMenuMode)ta.GetInt(Resource.Styleable.SlidingMenu_mode, (int)SlidingMenuMode.LEFT); this.Mode=mode; int viewAbove = ta.GetResourceId(Resource.Styleable.SlidingMenu_viewAbove, -1); if (viewAbove != -1) { setContent(viewAbove); } else { setContent(new FrameLayout(context)); } int viewBehind = ta.GetResourceId(Resource.Styleable.SlidingMenu_viewBehind, -1); if (viewBehind != -1) { setMenu(viewBehind); } else { setMenu(new FrameLayout(context)); } int touchModeAbove = ta.GetInt(Resource.Styleable.SlidingMenu_touchModeAbove, TOUCHMODE_MARGIN); setTouchModeAbove(touchModeAbove); int touchModeBehind = ta.GetInt(Resource.Styleable.SlidingMenu_touchModeBehind, TOUCHMODE_MARGIN); setTouchModeBehind(touchModeBehind); int offsetBehind = (int)ta.GetDimension(Resource.Styleable.SlidingMenu_behindOffset, -1); int widthBehind = (int)ta.GetDimension(Resource.Styleable.SlidingMenu_behindWidth, -1); if (offsetBehind != -1 && widthBehind != -1) throw new Java.Lang.IllegalStateException("Cannot set both behindOffset and behindWidth for a SlidingMenu"); else if (offsetBehind != -1) setBehindOffset(offsetBehind); else if (widthBehind != -1) setBehindWidth(widthBehind); else setBehindOffset(0); float scrollOffsetBehind = ta.GetFloat(Resource.Styleable.SlidingMenu_behindScrollScale, 0.33f); setBehindScrollScale(scrollOffsetBehind); int shadowRes = ta.GetResourceId(Resource.Styleable.SlidingMenu_shadowDrawable, -1); if (shadowRes != -1) { setShadowDrawable(shadowRes); } int shadowWidth = (int)ta.GetDimension(Resource.Styleable.SlidingMenu_shadowWidth, 0); setShadowWidth(shadowWidth); bool fadeEnabled = ta.GetBoolean(Resource.Styleable.SlidingMenu_fadeEnabled, true); setFadeEnabled(fadeEnabled); float fadeDeg = ta.GetFloat(Resource.Styleable.SlidingMenu_fadeDegree, 0.33f); setFadeDegree(fadeDeg); bool selectorEnabled = ta.GetBoolean(Resource.Styleable.SlidingMenu_selectorEnabled, false); setSelectorEnabled(selectorEnabled); int selectorRes = ta.GetResourceId(Resource.Styleable.SlidingMenu_selectorDrawable, -1); if (selectorRes != -1) setSelectorDrawable(selectorRes); ta.Recycle(); }
public LayoutParams(LayoutParams source) : base(source) { }
/** Create shadow wrapper with a pinned view for a view at given position */ void createPinnedShadow(int position) { // try to recycle shadow PinnedSection pinnedShadow = mRecycleSection; mRecycleSection = null; // create new shadow, if needed if (pinnedShadow == null) pinnedShadow = new PinnedSection(); // request new view using recycled view, if such View pinnedView = Adapter.GetView(position, pinnedShadow.view, this); // read layout parameters LayoutParams layoutParams = (LayoutParams) pinnedView.LayoutParameters; if (layoutParams == null) { // create default layout params layoutParams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); } MeasureSpecMode heightMode = MeasureSpec.GetMode(layoutParams.Height); int heightSize = MeasureSpec.GetSize(layoutParams.Height); if (heightMode == MeasureSpecMode.Unspecified) heightMode = MeasureSpecMode.Exactly; int maxHeight = Height - ListPaddingTop - ListPaddingBottom; if (heightSize > maxHeight) heightSize = maxHeight; // measure & layout int ws = MeasureSpec.MakeMeasureSpec(Width - ListPaddingLeft - ListPaddingRight, MeasureSpecMode.Exactly); int hs = MeasureSpec.MakeMeasureSpec(heightSize, heightMode); pinnedView.Measure(ws, hs); pinnedView.Layout(0, 0, pinnedView.MeasuredWidth, pinnedView.MeasuredHeight); mTranslateY = 0; // initialize pinned shadow pinnedShadow.view = pinnedView; pinnedShadow.position = position; pinnedShadow.id = Adapter.GetItemId(position); // store pinned shadow mPinnedSection = pinnedShadow; }
private void Init() { base.RemoveAllViews(); Orientation = Orientation.Vertical; cardImageView = new CardImageView(Context); cardImageView.SetCardImageWithoutAnimation(JudoSDKManager.GetCardResourceId(Context, currentCard, true)); LinearLayout layoutHolder = new LinearLayout(Context); layoutHolder.Orientation = Orientation.Horizontal; layoutHolder.SetGravity(GravityFlags.CenterVertical); LinearLayout cardFrame = new LinearLayout(Context); cardFrame.SetGravity(GravityFlags.CenterVertical); cardFrame.SetPadding(UiUtils.ToPixels(Context, 8), 0, UiUtils.ToPixels(Context, 8), 0); cardFrame.AddView(cardImageView); LayoutParams parameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); parameters.Gravity = GravityFlags.Center; cardNumberTextView = new CardNumberTextView(Context); cardNumberTextView.LayoutParameters = parameters; cardExpiryCv2TextView = new CardExpiryCV2TextView(Context, null, Resource.Style.judo_payments_CardText); cardExpiryCv2TextView.LayoutParameters = parameters; cardExpiryCv2TextView.Visibility = ViewStates.Invisible; layoutHolder.AddView(cardFrame, LayoutParams.WrapContent, LayoutParams.MatchParent); layoutHolder.AddView(cardNumberTextView); layoutHolder.AddView(cardExpiryCv2TextView); AddView(layoutHolder); int lastPos = 0; CardBase.CardType currentCardType; cardNumberTextView.OnEntryComplete += cardNumber => { if (OnCreditCardEntered != null) { OnCreditCardEntered(cardNumber); } SetStage(Stage.STAGE_CC_EXP); }; cardNumberTextView.OnProgress += position => { if (position == 0) { return; } string cardNumber = cardNumberTextView.GetText(); currentCardType = ValidationHelper.GetCardType(cardNumber); if (currentCardType != currentCard) { if (currentCard == CardBase.CardType.AMEX && !JudoSDKManager.Configuration.IsAVSEnabled) { cardNumberTextView.ShowInvalid("AmEx not accepted"); } else if (currentCard == CardBase.CardType.MASTRO && !JudoSDKManager.Configuration.IsMaestroEnabled) { cardNumberTextView.ShowInvalid("Maestro not accepted"); } else { cardImageView.SetCardImage(JudoSDKManager.GetCardResourceId(Context, currentCardType, true), false); cardNumberTextView.SetHintText(JudoSDKManager.GetCardHintFormat(currentCardType)); cardExpiryCv2TextView.SetHintText(JudoSDKManager.GetExpiryAndValidationHintFormat(currentCardType)); cardExpiryCv2TextView.SetErrorText(JudoSDKManager.GetExpiryAndValidationErrorMessage(currentCardType)); } currentCard = currentCardType; } lastPos = position; }; cardExpiryCv2TextView.OnEntryComplete += expiryAndCV2 => { string[] temp = expiryAndCV2.Split(' '); if (temp.Length < 2) { Log.Error(this.ToString(), "Error: Invalid expiry and/or cv2"); return; } var expiry = temp[0]; var cv2 = temp[1]; if (OnExpireAndCV2Entered != null) { OnExpireAndCV2Entered(expiry, cv2); } }; cardExpiryCv2TextView.OnProgress += position => { cardExpiryCv2TextView.ValidatePartialInput(); if (position > 4) { cardImageView.SetCardImage(JudoSDKManager.GetCardResourceId(Context, currentCard, false), true); if (HintTextView != null) { HintTextView.SetText(Resource.String.enter_card_cv2); } if (position == 5) { try { cardExpiryCv2TextView.ValidateExpiryDate(cardExpiryCv2TextView.GetText()); } catch (Exception e) { cardExpiryCv2TextView.ShowInvalid(e.Message); } } } else { cardImageView.SetCardImage(JudoSDKManager.GetCardResourceId(Context, currentCard, true), true); if (HintTextView != null) { HintTextView.SetText(Resource.String.enter_card_expiry); } } }; cardExpiryCv2TextView.OnBackKeyPressed = () => { if (cardExpiryCv2TextView.GetText().Length == 0) { cardExpiryCv2TextView.SetText(""); SetStage(Stage.STAGE_CC_NO); } }; }
private void UpdatePosition(View view, int left, int top, int width, int height) { LayoutParams param = new LayoutParams(width, height, left, top); view.LayoutParameters = param; }