Пример #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var rootView = inflater.Inflate(Resource.Layout.ztranslation, container, false);


            //Find view to apply Z-translation to
            floatingShape = rootView.FindViewById(Resource.Id.circle);

            //Create the outlines
            mOutline = new Outline();

            circleProvider = new CircleOutlineProvider();
            circleProvider.GetOutline(floatingShape, mOutline);

            rectProvider = new RectOutlineProvider();
            rectProvider.GetOutline(floatingShape, mOutline);

            /*
             * //Define the view's shape
             * floatingShape.OutlineProvider = circleProvider;
             * //Clip view to outline
             * floatingShape.ClipToOutline = true;
             */
            var dragLayout = rootView.FindViewById <DragFrameLayout> (Resource.Id.main_layout);

            dragLayout.mDragFrameLayoutController = new DragFrameLayoutController((bool captured) => {
                floatingShape.Animate()
                .TranslationZ(captured ? 50 : 0)
                .SetDuration(100);
                Log.Debug(TAG, captured ? "drag" : "drop");
            });

            dragLayout.AddDragView(floatingShape);

            rootView.FindViewById(Resource.Id.raise_bt).Click += delegate {
                mElevation += ELEVATION_STEP;
                Log.Debug(TAG, string.Format("Elevation: {0:0.#}", mElevation));
                floatingShape.Elevation = mElevation;
            };

            rootView.FindViewById(Resource.Id.lower_bt).Click += delegate {
                mElevation = Math.Max(mElevation - ELEVATION_STEP, 0);
                Log.Debug(TAG, string.Format("Elevation: {0:0.#}", mElevation));
                floatingShape.Elevation = mElevation;
            };

            /* Create a spinner with options to change the shape of the object. */
            var spinner = rootView.FindViewById <Spinner> (Resource.Id.shapes_spinner);

            spinner.Adapter = new ArrayAdapter <string> (
                this.Activity,
                Android.Resource.Layout.SimpleSpinnerDropDownItem,
                this.Resources.GetStringArray(Resource.Array.shapes));

            spinner.OnItemSelectedListener = this;
            return(rootView);
        }
		public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
		{
			var rootView = inflater.Inflate (Resource.Layout.ztranslation, container, false);


			//Find view to apply Z-translation to
			floatingShape = rootView.FindViewById (Resource.Id.circle);

			//Create the outlines
			mOutline = new Outline ();

			circleProvider = new CircleOutlineProvider ();
			circleProvider.GetOutline (floatingShape, mOutline);

			rectProvider = new RectOutlineProvider ();
			rectProvider.GetOutline (floatingShape, mOutline);
			/*
			//Define the view's shape
			floatingShape.OutlineProvider = circleProvider;
			//Clip view to outline
			floatingShape.ClipToOutline = true;
			*/
			var dragLayout = rootView.FindViewById<DragFrameLayout> (Resource.Id.main_layout);

			dragLayout.mDragFrameLayoutController = new DragFrameLayoutController ((bool captured) => {
				floatingShape.Animate ()
					.TranslationZ (captured ? 50 : 0)
					.SetDuration (100);
				Log.Debug (TAG, captured ? "drag" : "drop");
			});

			dragLayout.AddDragView (floatingShape);

			rootView.FindViewById (Resource.Id.raise_bt).Click += delegate {
				mElevation += ELEVATION_STEP;
				Log.Debug (TAG, string.Format ("Elevation: {0:0.#}", mElevation));
				floatingShape.Elevation = mElevation;
			};

			rootView.FindViewById (Resource.Id.lower_bt).Click += delegate {
				mElevation = Math.Max (mElevation - ELEVATION_STEP, 0);
				Log.Debug (TAG, string.Format ("Elevation: {0:0.#}", mElevation));
				floatingShape.Elevation = mElevation;
			};

			/* Create a spinner with options to change the shape of the object. */
			var spinner = rootView.FindViewById<Spinner> (Resource.Id.shapes_spinner);
			spinner.Adapter = new ArrayAdapter<string> (
				this.Activity,
				Android.Resource.Layout.SimpleSpinnerDropDownItem,
				this.Resources.GetStringArray (Resource.Array.shapes));

			spinner.OnItemSelectedListener = this;
			return rootView;
		}