Android: Dialogs have extra, ugly space on droid 3?

后端 未结 1 1796
半阙折子戏
半阙折子戏 2021-01-22 18:58

The first image is from a Galaxy Note, the second is from a Droid 3. Both of them produced from the below code.

The dialog on the Droid 3 has a significant amount of

1条回答
  •  再見小時候
    2021-01-22 19:27

    These Droid UI customizations drive me crazy!

    If you'd like to control your dialogs to make them consistent across devices, you can strip them down to the basics with a constructor that supplies a style parameter. The following example gives a dialog that looks like this:

    sample dialog

    First, instantiate your dialog like this (or better yet, create a custom class that extends Dialog so you can reuse it):

    Dialog dialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar);
    dialog.setContentView(R.layout.custom_dialog_layout);
    

    Then, supply a custom_dialog_layout.xml (could look something like this):

    
    
    
        
    
            
    
            
    
        
    
    

    where dialog_background.xml looks something like this:

    
    
    
        
    
        
    
        
    
    
    

    And if you really want to get fancy, you could try applying a drop shadow to the dialog_layout in code using something like this SO answer: https://stackoverflow.com/a/3723654/475217

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