Fully custom dialog in Android with the same look regardless device

后端 未结 4 1584
离开以前
离开以前 2020-12-19 18:49

I have to build a dialog that looks exactly the same across different devices regardless of the OS theme. At the moment, I created an AlertDialog and I call

相关标签:
4条回答
  • 2020-12-19 18:56

    For doing custom dialog look at the tutorial it is great http://developer.android.com/guide/topics/ui/dialogs.html about the borders see here http://developer.android.com/guide/topics/ui/dialogs.html you may also make use of this It have some great Ideas

    0 讨论(0)
  • 2020-12-19 18:57

    create xml file. and use this java code.

                            info_dialog = new Dialog(ActivityName.this);
                            info_dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                            info_dialog.setContentView(R.layout.info);                          
                            info_dialog.show();
    
    0 讨论(0)
  • 2020-12-19 19:06

    You can specify Themes in views or activities. Have a look at this link

    0 讨论(0)
  • 2020-12-19 19:12

    Go for this

    import android.app.Dialog;
    import android.content.Context;
    import android.os.Bundle;
    
    public class FullyscutomDialo extends Dialog{
    
    public FullyscutomDialo(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
    }
    
    @Override
    public void dismiss() {
        //do what you need before closing here
        super.dismiss();
    }
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //set your custom layout here
        //use layout attribut just like activity
    }
    
     }
    

    then use two line to show it from activity(May be onclickevent etc)

             FullyscutomDialo hh=new FullyscutomDialo (this);
             hh.show()
    

    Edited For Transparent Dialog

    use In onCreate of dialog class

     this.getWindow().setBackgroundDrawable(new ColorDrawable(0));
    

    Cheers :):)

    0 讨论(0)
提交回复
热议问题