orhanobut / dialogplus

Advanced dialog solution for android
Apache License 2.0
5k stars 793 forks source link

bottom padding added to custom layout #164

Closed buelersandra closed 6 years ago

buelersandra commented 6 years ago

Same issue here Below is the xml preview: screen shot 2018-05-17 at 9 05 40 am

This is the dialog (with bottom padding) 32599578_1846004902371807_2061262381396262912_n

This is my code. `dialogplus = DialogPlus.newDialog(this)

            .setContentHolder(new Holder() {
                @Override
                public void addHeader(View view) {

                }

                @Override
                public void addFooter(View view) {

                }

                @Override
                public void setBackgroundResource(int colorResource) {

                }

                @Override
                public View getView(LayoutInflater inflater, ViewGroup parent) {
                    View view=inflater.inflate(R.layout.notification_popup,parent,false);
                    FancyButton btn=(FancyButton)view.findViewById(R.id.updatebtn);
                    nview=(View)view.findViewById(R.id.mainparent);
                    ImageView closebtn=(ImageView)view.findViewById(R.id.closebtn);
                    btn.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                                String packageName="com.fhoodi";
                                Intent intent = null;
                                try {
                                    intent = new Intent(Intent.ACTION_VIEW);
                                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                    intent.setData(Uri.parse("market://details?id=" + packageName));
                                    getApplicationContext().startActivity(intent);
                                } catch (android.content.ActivityNotFoundException anfe) {
                                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + packageName)));
                                }

                        }
                    });

                    closebtn.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            dialogplus.dismiss();
                        }
                    });

                    return view;
                }

                @Override
                public void setOnKeyListener(View.OnKeyListener keyListener) {

                }

                @Override
                public View getInflatedView() {
                    return nview;
                }

                @Override
                public View getHeader() {
                    return null;
                }

                @Override
                public View getFooter() {
                    return null;
                }
            })
            .setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(DialogPlus dialog, View view) {
                    if(view.getId()==R.id.closebtn){
                        dialog.dismiss();
                    }
                }
            })
            .setContentWidth(ViewGroup.LayoutParams.WRAP_CONTENT)  // or any custom width ie: 300
            .setContentHeight(ViewGroup.LayoutParams.WRAP_CONTENT)
            .setInAnimation(R.anim.abc_fade_in)
            .setOutAnimation(R.anim.abc_fade_out)
            .setPadding(20,20,20,0)
            .setGravity(Gravity.TOP)
            .setCancelable(false)
            .setExpanded(true)  // This will enable the expand feature, (similar to android L share dialog)
            .create();
    dialogplus.show();`
buelersandra commented 6 years ago

i realised .setExpanded(true) wasn't necessary and was causing the padding to be created.