Ejemplo n.º 1
0
        private void resizeDialog()
        {
            WindowManagerLayoutParams _params = Window.Attributes;

            _params.Width     = (int)(DisplayUtil.getScreenSize(_context).X * 0.7);
            Window.Attributes = _params;
        }
Ejemplo n.º 2
0
        private void initView()
        {
            View contentView = View.Inflate(Context, Resource.Layout.layout_promptdialog, null);

            SetContentView(contentView);
            resizeDialog();

            mDialogView  = Window.DecorView.FindViewById(Android.Resource.Id.Content);
            mTitleTv     = (TextView)contentView.FindViewById(Resource.Id.tvTitle);
            mContentTv   = (TextView)contentView.FindViewById(Resource.Id.tvContent);
            mPositiveBtn = (TextView)contentView.FindViewById(Resource.Id.btnPositive);

            View      llBtnGroup = FindViewById(Resource.Id.llBtnGroup);
            ImageView logoIv     = (ImageView)contentView.FindViewById(Resource.Id.logoIv);

            logoIv.SetBackgroundResource(getLogoResId(mDialogType));

            LinearLayout topLayout  = (LinearLayout)contentView.FindViewById(Resource.Id.topLayout);
            ImageView    triangleIv = new ImageView(Context);

            triangleIv.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, DisplayUtil.dp2px(Context, 10));

            triangleIv.SetImageBitmap(createTriangel((int)(DisplayUtil.getScreenSize(_context).X * 0.7), DisplayUtil.dp2px(_context, 10)));

            topLayout.AddView(triangleIv);

            setBtnBackground(mPositiveBtn);
            setBottomCorners(llBtnGroup);


            int radius = DisplayUtil.dp2px(Context, DEFAULT_RADIUS);

            float[]        outerRadii     = new float[] { radius, radius, radius, radius, 0, 0, 0, 0 };
            RoundRectShape roundRectShape = new RoundRectShape(outerRadii, null, null);
            ShapeDrawable  shapeDrawable  = new ShapeDrawable(roundRectShape);

            shapeDrawable.Paint.SetStyle(Paint.Style.Fill);
            shapeDrawable.Paint.Color = Context.Resources.GetColor(getColorResId(mDialogType));
            LinearLayout llTop = (LinearLayout)FindViewById(Resource.Id.llTop);

            llTop.Background = shapeDrawable;

            mTitleTv.Text     = mTitle;
            mContentTv.Text   = mContent;
            mPositiveBtn.Text = mBtnText;
        }