コード例 #1
0
 protected ViewGroup.LayoutParams CreateLayoutParams(UIElement element)
 {
     var layoutParams = new ViewGroup.LayoutParams(0, 0);
     layoutParams.Width = double.IsNaN(element.Width) ? ViewGroup.LayoutParams.FillParent : (int)element.Width;
     layoutParams.Height = double.IsNaN(element.Height) ? ViewGroup.LayoutParams.FillParent : (int)element.Height;
     return layoutParams;
 }
コード例 #2
0
 public ExtendedCellTableLayout(Context context)
     : base(context)
 {
     StretchAllColumns = true;
     LayoutParameters =
         new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
 }
コード例 #3
0
		public View InflateViews ()
		{
			mScrollView = new ScrollView (Activity);
			ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams (
				ViewGroup.LayoutParams.MatchParent,
				ViewGroup.LayoutParams.MatchParent);
			mScrollView.LayoutParameters = scrollParams;

			mLogView = new LogView (Activity);
			ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams (scrollParams);
			logParams.Height = ViewGroup.LayoutParams.WrapContent;
			mLogView.LayoutParameters = logParams;
			mLogView.Clickable = true;
			mLogView.Focusable = true;
			mLogView.Typeface = Typeface.Monospace;

			// Want to set padding as 16 dips, setPadding takes pixels.  Hooray math!
			int paddingDips = 16;
			float scale = Resources.DisplayMetrics.Density;
			int paddingPixels = (int) ((paddingDips * (scale)) + .5);
			mLogView.SetPadding (paddingPixels, paddingPixels, paddingPixels, paddingPixels);
			mLogView.CompoundDrawablePadding = paddingPixels;

			mLogView.Gravity = GravityFlags.Bottom;
			mLogView.SetTextAppearance (Activity, Android.Resource.Style.TextAppearanceMedium);

			mScrollView.AddView (mLogView);
			return mScrollView;
		}
コード例 #4
0
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            var p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            var view = new LinearLayout(_context);
            view.LayoutParameters = p;

            var optionHolder = new LinearLayout(_context);
            optionHolder.Orientation = Orientation.Vertical;
            optionHolder.LayoutParameters = p;

            foreach (var option in _options)
            {
                optionHolder.AddView(AddCategoryRow(option));
            }
            var scrollView = new ScrollView(_context);
            scrollView.LayoutParameters = p;
            scrollView.AddView(optionHolder);
            view.AddView(scrollView);

            var dialog = new Android.Support.V7.App.AlertDialog.Builder(_context);
            dialog.SetTitle(_title);
            dialog.SetView(view);
            //dialog.SetNegativeButton("Cancel", (s, a) => { });
            dialog.SetPositiveButton("Ok", (s, a) => { });
            return dialog.Create();
        }
コード例 #5
0
 public SingleStringDialogFragment(Context context, string title, List<KeyValuePair<object, object>> options)
 {
     _context = context;
     _title = title;
     _options = options;
     rowParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, PixelConverter.DpToPixels(40));
     textParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
 }
コード例 #6
0
ファイル: StandardLibrary.cs プロジェクト: atsushieno/tsukimi
 protected override void OnCreate(Android.OS.Bundle savedInstanceState)
 {
     base.OnCreate (savedInstanceState);
     var view = new ProcessingApplication (this, run, this.BaseContext);
     var lp = new ViewGroup.LayoutParams (ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
     view.LayoutParameters = lp;
     view.Holder.AddCallback (view);
     this.SetContentView (view);
 }
コード例 #7
0
ファイル: FormsViewHelper.cs プロジェクト: kiwaa/XfPopups
		// Code taken from 
		// http://www.michaelridland.com/xamarin/creating-native-view-xamarin-forms-viewpage/
        public static ViewGroup ConvertFormsToNative(Xamarin.Forms.View view, Xamarin.Forms.Rectangle size)
        {
            var renderer = Platform.CreateRenderer(view);
            var viewGroup = renderer.ViewGroup;
            renderer.Tracker.UpdateLayout();
            var layoutParams = new ViewGroup.LayoutParams((int)size.Width, (int)size.Height);
            viewGroup.LayoutParameters = layoutParams;
            view.Layout(size);
            viewGroup.Layout(0, 0, (int)view.WidthRequest, (int)view.HeightRequest);
            return viewGroup;
        }
コード例 #8
0
        public static ViewGroup ConvertFormsToNative(Xamarin.Forms.View view, Rectangle size)
        {
			//var vRenderer = RendererFactory.GetRenderer (view);

			if (Platform.GetRenderer(view) == null)
				Platform.SetRenderer(view, Platform.CreateRenderer(view));
			var vRenderer = Platform.GetRenderer(view);

            
            var viewGroup = vRenderer.ViewGroup;
            vRenderer.Tracker.UpdateLayout ();
            var layoutParams = new ViewGroup.LayoutParams ((int)size.Width, (int)size.Height);
            viewGroup.LayoutParameters = layoutParams;
            view.Layout (size);
            viewGroup.Layout (0, 0, (int)view.WidthRequest, (int)view.HeightRequest);
            return viewGroup; 
        }
コード例 #9
0
ファイル: Canvas.Droid.cs プロジェクト: evnik/UIFramework
        protected internal override void NativeInit()
        {
            if (this.Parent != null && this.Context != null)
            {
                if (this.NativeUIElement == null)
                {
                    var nativeCanvas = new NativeCanvas(this.Context);

                    var layoutParams = new ViewGroup.LayoutParams(0, 0);

                    layoutParams.Width = double.IsNaN(this.NativeWidth) ? ViewGroup.LayoutParams.WrapContent : (int)this.NativeWidth;
                    layoutParams.Height = double.IsNaN(this.NativeHeight) ? ViewGroup.LayoutParams.WrapContent : (int)this.NativeHeight;
                    nativeCanvas.LayoutParameters = layoutParams;
                    this.NativeUIElement = nativeCanvas;
                }
            }
            base.NativeInit();
        }
コード例 #10
0
        void AddSubCategories()
        {
            ViewGroup.LayoutParams p = new ViewGroup.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);

            var index = 0;
            foreach (var item in items)
            {
                LinearLayout row = new LinearLayout(context);
                row.Orientation = Orientation.Horizontal;
                row.LayoutParameters = p;

                TextView subCategory = new TextView(context);
                subCategory.LayoutParameters = p;

                subCategory.Gravity = GravityFlags.CenterVertical;
                subCategory.SetTextSize(Android.Util.ComplexUnitType.Px, rowHeight * 0.40f);
                subCategory.SetPadding((int)(rowHeight * 0.1), (int)(rowHeight * 0.15), (int)(rowHeight * 0.1), (int)(rowHeight * 0.15));

                subCategory.Text = item.Value;
                row.AddView(subCategory);

                row.Click += (object sender, EventArgs e) =>
                {
                    row.SetBackgroundResource(Android.Resource.Color.HoloBlueLight);
                    if (this.CategorySelected != null)
                        this.CategorySelected(this, new CategorySelectedEventArgs { Selected = item });
                };

                row.LongClick += (sender, e) =>
                {
                    if (this.CategoryLongClick != null)
                        CategoryLongClick(this, new CategorySelectedEventArgs { Selected = item, SelectedView = row });
                };

                AddView(row);
                index++;
            }
        }
コード例 #11
0
		/**
     * Add a fixed view to appear at the top of the grid. If addHeaderView is
     * called more than once, the views will appear in the order they were
     * added. Views added using this call can take focus if they want.
     * <p/>
     * NOTE: Call this before calling setAdapter. This is so HeaderGridView can wrap
     * the supplied cursor with one that will also account for header views.
     *
     * @param v            The view to add.
     * @param data         Data to associate with this view
     * @param isSelectable whether the item is selectable
     */
		public void AddHeaderView(View v, Object data, bool isSelectable) {
			IListAdapter adapter = Adapter;
			if (adapter != null && !(adapter is HeaderViewGridAdapter)) {
				throw new Java.Lang.IllegalStateException(
					"Cannot add header view to grid -- setAdapter has already been called.");
			}
			ViewGroup.LayoutParams lyp = v.LayoutParameters;

			FixedViewInfo info = new FixedViewInfo();
			FrameLayout fl = new FullWidthFixedViewLayout(Context,this);
			if (lyp == null) {
				lyp = new ViewGroup.LayoutParams (WindowManagerLayoutParams.MatchParent,WindowManagerLayoutParams.MatchParent);
			}

			if (lyp != null) {
				v.LayoutParameters=new FrameLayout.LayoutParams(lyp.Width, lyp.Height);
				fl.LayoutParameters=new AbsListView.LayoutParams(lyp.Width, lyp.Height);
			}
			fl.AddView(v);
			info.view = v;
			info.viewContainer = fl;
			info.data = data;
			info.isSelectable = isSelectable;
			_headerViewInfos.Add(info);
			// in the case of re-adding a header view, or adding one later on,
			// we need to notify the observer
			if (adapter != null) {
				((HeaderViewGridAdapter) adapter).notifyDataSetChanged();
			}
		}
コード例 #12
0
ファイル: AppMsg.cs プロジェクト: wnf0000/AppMsg
 public AppMsg SetDisplayPosition(DisplayPosition position)
 {
     var gravity = ConvertPosition(position);
     mLayoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent,
                                                  ViewGroup.LayoutParams.WrapContent, gravity);
     return this;
 }
コード例 #13
0
 public AnimatorUpdateListener(bool isPortrait, View titlesView, ViewGroup.LayoutParams lp)
 {
     this.isPortrait = isPortrait;
     this.titlesView = titlesView;
     this.lp = lp;
 }
コード例 #14
0
        public void OnGlobalLayout()
        {
            // the wrapper must have 1 or 2 children, any more or less
            // is an error
            if (ChildCount == 0 || ChildCount > 2) {
                throw new ArgumentOutOfRangeException(String.Format("Wrapper must have 1 or 2 children, found {0}",
                                                                    ChildCount));
            }

            if (ChildCount == 1) {
                // inject our header
                var header = LayoutInflater.FromContext(Context)
                    .Inflate(Resource.Layout.ptrsharp_header, this, false);

                // set any custom icon drawable here so the next layout pass
                // will have already accounted for it's dimensions
                if (pulldown_icon_drawable_res_id > 0) {
                    var icon = header.FindViewById<ImageView>(Resource.Id.icon);
                    icon.SetImageResource(pulldown_icon_drawable_res_id);
                }

                // set the header height to be as tall as the display
                var lp = new ViewGroup.LayoutParams(header.LayoutParameters);
                lp.Height = Context.Resources.DisplayMetrics.HeightPixels;
                header.LayoutParameters = lp;

                AddView(header, 0);
                // return now and this will get called again and we can
                // proceed as usual
                return;
            }

            // find our children and glean the measured size of the header
            if (header_measured_height == 0) {
                if (header_res_id > 0) {
                    Header = FindViewById<ViewGroup>(header_res_id);
                } else {
                    Header = (ViewGroup)GetChildAt(0);
                }

                if (header_background_res_id > 0) {
                    Header.SetBackgroundResource(header_background_res_id);
                }

                if (header_text_color != null) {
                    var text_view = Header.FindViewById<TextView>(Resource.Id.text);
                    if (text_view != null) {
                        text_view.SetTextColor(header_text_color);
                    }
                }

                // Header should not be null at this point, if it is something is totally wrong
                // so I'm not checking for null.
                // TODO: Possibly add an attribute to define the id of the inner header
                inner_header = (ViewGroup)Header.GetChildAt(0);

                if (content_view_res_id > 0) {
                    ContentView = (IPullToRefresharpWrappedView)FindViewById<View>(content_view_res_id);
                } else {
                    ContentView = (IPullToRefresharpWrappedView)GetChildAt(1);
                }

                if (pulldown_progress_indicator_res_id > 0) {
                    pulldown_progress_indicator = FindPullDownProgressIndicator(pulldown_progress_indicator_res_id);
                } else {
                    pulldown_progress_indicator = FindPullDownProgressIndicator(Resource.Id.pullDownProgressIndicator);
                }

                ContentView.RefreshCompleted += ptrView_RefreshCompleted;

                header_measured_height = inner_header.Height;
                UpdateHeaderTopMargin(-Header.Height);

                // set initial text
                refresh_text = FindViewById<TextView>(Resource.Id.text);
                refresh_text.Text = Resources.GetString(pull_to_refresh_string_id);
            }

            if (header_measured_height > 0) {
                Header.ViewTreeObserver.RemoveGlobalOnLayoutListener(this);
            }
        }
コード例 #15
0
 // TODO: Looks like redundant, because LayoutParams is generated in the UIElement
 protected ViewGroup.LayoutParams CreateLayoutParams()
 {
     var layoutParams = new ViewGroup.LayoutParams(0, 0);
     layoutParams.Width = ViewGroup.LayoutParams.WrapContent;
     layoutParams.Height = ViewGroup.LayoutParams.WrapContent;
     return layoutParams;
 }
コード例 #16
0
ファイル: ExpandHelper.cs プロジェクト: Andrea/FriendTab
			public void SetView(View v)
			{
				mView = v;
				pars = v.LayoutParameters;
			}
コード例 #17
0
    private void MeasureView(View child)
    {
      ViewGroup.LayoutParams p = child.LayoutParameters;
      if (p == null)
        p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent);

      int childWidthSpec = ViewGroup.GetChildMeasureSpec(0, 0 + 0, p.Width);
      int lpHeight = p.Height;
      int childHeightSpec;
      if (lpHeight > 0)
      {
        childHeightSpec = MeasureSpec.MakeMeasureSpec(lpHeight, MeasureSpecMode.Exactly);
      }
      else
      {
        childHeightSpec = MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);
      }
      child.Measure(childWidthSpec, childHeightSpec);
    }
コード例 #18
0
        protected internal override void NativeInit()
        {
            if (this.Parent != null)
            {
                if (this.NativeUIElement == null)
                {
                    this.NativeUIElement = new NativeMediaElement(this.Context);
                    this.videoView = new WrapedVideoView(this.Context);
                    ((NativeMediaElement)this.NativeUIElement).AddView((WrapedVideoView)this.videoView);

                    var layoutParams = new ViewGroup.LayoutParams(0, 0);

                    layoutParams.Width = double.IsNaN(this.NativeWidth) ? ViewGroup.LayoutParams.FillParent : (int)this.NativeWidth;
                    layoutParams.Height = double.IsNaN(this.NativeHeight) ? ViewGroup.LayoutParams.FillParent : (int)this.NativeHeight;
                    this.NativeUIElement.LayoutParameters = layoutParams;
                    ((WrapedVideoView)this.videoView).LayoutParameters = layoutParams;

                    ((WrapedVideoView)this.videoView).InitMediaPlayer();

                    ((WrapedVideoView)this.videoView).VideoSizeChanged -= MediaElement_VideoSizeChanged;
                    ((WrapedVideoView)this.videoView).VideoSizeChanged += MediaElement_VideoSizeChanged;

                    ((WrapedVideoView)this.videoView).BufferingProgressUpdate -= MediaElement_BufferingProgressUpdate;
                    ((WrapedVideoView)this.videoView).BufferingProgressUpdate += MediaElement_BufferingProgressUpdate;

                    if (this.ReadLocalValue(MediaElement.AudioStreamIndexProperty) != DependencyProperty.UnsetValue)
                    {
                        this.ApplyNativeAudioStreamIndex(this.NativeAudioStreamIndex);
                    }

                    if (this.ReadLocalValue(MediaElement.AutoPlayProperty) != DependencyProperty.UnsetValue)
                    {
                        this.ApplyNativeAutoPlay(this.NativeAutoPlay);
                    }

                    if (this.ReadLocalValue(MediaElement.BalanceProperty) != DependencyProperty.UnsetValue)
                    {
                        this.ApplyNativeBalance(this.NativeBalance);
                    }

                    if (this.ReadLocalValue(MediaElement.IsMutedProperty) != DependencyProperty.UnsetValue)
                    {
                        ApplyNativeIsMuted(this.NativeIsMuted);
                    }

                    if (this.ReadLocalValue(MediaElement.PositionProperty) != DependencyProperty.UnsetValue)
                    {
                        this.ApplyNativePosition(this.nativePosition);
                    }

                    if (this.ReadLocalValue(MediaElement.SourceProperty) != DependencyProperty.UnsetValue)
                    {
                        this.ApplyNativeSource(this.NativeSource);
                    }

                    if (this.ReadLocalValue(MediaElement.StretchProperty) != DependencyProperty.UnsetValue)
                    {
                        this.ApplyNativeStretch(this.NativeStretch);
                    }

                    if (this.ReadLocalValue(MediaElement.VolumeProperty) != DependencyProperty.UnsetValue)
                    {
                        this.ApplyNativeVolume(this.nativeVolume);
                    }
                }

                base.NativeInit();
            }
        }
コード例 #19
0
        void AddTabTypeBadges(IEnumerable<Tuple<TabType, Bitmap>> badges, LayoutInflater inflater)
        {
            foreach (var b in badges) {
                var type = b.Item1;
                var bmp = b.Item2;

                var layout = new ViewGroup.LayoutParams (ViewGroup.LayoutParams.WrapContent,
                                                         ViewGroup.LayoutParams.WrapContent);
                var badge = new CategoryBadge (inflater.Context) {
                    ItemName = type.Name,
                    IconDrawable = bmp
                };
                categoryPlaceholder.AddView (badge, categoryPlaceholder.ChildCount - 1, layout);
                BadgeInstances[type.Name] = badge;
            }
        }
コード例 #20
0
        void Initialize()
        {
            ViewGroup.LayoutParams p = new ViewGroup.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
            this.Orientation = Orientation.Vertical;

            LinearLayout row = new LinearLayout(context);
            row.Orientation = Orientation.Horizontal;
            row.LayoutParameters = p;
            row.SetBackgroundResource(Resource.Color.headerColor);

            headerLabel = new TextView(context);
            headerLabel.LayoutParameters = p;
            //headerLabel.SetTextSize(ComplexUnitType.Dip, 20);

            headerLabel.Gravity = GravityFlags.CenterVertical;
            headerLabel.SetTextSize(Android.Util.ComplexUnitType.Px, rowHeight * 0.50f);
            headerLabel.SetPadding((int)(rowHeight * 0.1), (int)(rowHeight * 0.15), (int)(rowHeight * 0.1), (int)(rowHeight * 0.15));

            row.AddView(headerLabel);

            AddView(row);
        }
コード例 #21
0
 public AppMsg SetLayoutGravity(GravityFlags gravity)
 {
     mLayoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent, gravity);
     return this;
 }
コード例 #22
0
ファイル: MainActivity.cs プロジェクト: edward93/Equalizer
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var svvl = FindViewById<LinearLayout>(Resource.Id.VerticalLayoutScroll);
            var addButton = FindViewById<Button>(Resource.Id.AddNewFields);
            var calcBtn = FindViewById(Resource.Id.Calculate);

            var layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent,
                    ViewGroup.LayoutParams.WrapContent);
            var textFieldLayoutParams = new TableLayout.LayoutParams(0, ViewGroup.LayoutParams.MatchParent, 1);

            //Add Button Click Event
            addButton.Click += (sender, eventArgs) =>
            {
                var linearLayout = new LinearLayout(this)
                {
                    Orientation = Orientation.Horizontal,
                    LayoutParameters = layoutParams,
                    WeightSum = 2
                };

                var nameField = new EditText(this)
                {
                    InputType = InputTypes.ClassText,
                    LayoutParameters = textFieldLayoutParams,
                    Hint = "Name of a Person"
                };

                var moneyField = new EditText(this)
                {
                    InputType = InputTypes.ClassNumber,
                    LayoutParameters = textFieldLayoutParams,
                    Hint = "Spent Money"
                };

                linearLayout.AddView(nameField);
                linearLayout.AddView(moneyField);
                svvl.AddView(linearLayout);
            };

            calcBtn.Click += (sender, eventArgs) =>
            {
                var personsList = new List<Person>();
                for (var i = 0; i < svvl.ChildCount; i++)
                {
                    var child = svvl.GetChildAt(i);

                    if (!(child is LinearLayout)) continue;
                    var editText = (child as LinearLayout).GetChildAt(0) as EditText;
                    var text = (child as LinearLayout).GetChildAt(1) as EditText;
                    if (editText != null && text != null && !string.IsNullOrEmpty(editText.Text))
                    {
                        personsList.Add(new Person
                        {
                            Name = editText.Text,
                            SpentMoney = !string.IsNullOrEmpty(text.Text) ? Convert.ToDecimal(text.Text) : 0,
                        });
                    }
                }
                var finalList = Person.CalculateMoney(personsList);
                var intent = new Intent(this, typeof (ResultActivity));
                string result = null;
                if (finalList != null)
                {
                    foreach (var person in finalList)
                    {
                        if (person.WhoAndHow != null)
                            result = person.WhoAndHow.Aggregate(result,
                                (current, item) =>
                                    current +
                                    (person.Name + " needs to give " + item.Value + " AMD to " + item.Key +
                                     System.Environment.NewLine));
                    }
                }
                intent.PutExtra("Result", result);
                StartActivity(intent);
            };
        }