how to programatically theme an activity to be like a dialog?

前端 未结 3 1987
野的像风
野的像风 2020-12-08 17:25

Question

How does one programatically (without touching the AndroidManifext.xml) set the theme of an Activity so that it looks like a dia

3条回答
  •  青春惊慌失措
    2020-12-08 17:51

    Try these code before dailog.setMessage(...);

    Dialog id  = new AlertDialog.Builder(this,AlertDialog.THEME_DEVICE_DEFAULT_DARK);
    
    Dialog ID = new AlertDialog.Builder(this,AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
    
    //Default theme 
    

    Try this for Old theme Dialog ID = new AlertDialog.Builder(this,AlertDialog.THEME_TRADITIONAL);

    Try these for KITKAT theme

    Dialog ID = new AlertDialog.Builder(this,AlertDialog.THEME_DEVICE_DEFAULT_DARK); //Dark
    
    
    Dialog ID = new AlertDialog.Builder(this,AlertDialog.THEME_HOLO_LIGHT);
    

    Try these codes for Pragmatically

    Exmaple

        dialog = new AlertDialog.Builder(this);
                dialog = new AlertDialog.Builder(this,AlertDialog.THEME_DEVICE_DEFAULT_DARK);
                dialog.setTitle("HAI");
                dialog.setMessage("look");
                dialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
    Toast toast= Toast.makeText(getApplicationContext(), "This is exmaple theme", Toast.LENGTH_LONG);
    

提交回复
热议问题