Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
445 views
in Technique[技术] by (71.8m points)

android - remove border, padding from Dialog

I have an activity which is with the theme Theme.Transparent which is:

<style name="Theme.Transparent" parent="android:Theme.Dialog">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:backgroundDimEnabled">false</item>
    <item name="android:gravity">top</item>
</style>

i'm trying to get rid of the border and the padding around it.. i want to make fill the horizontal of the screen. and no gray border. please help :) enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Be sure to create your Dialog referencing your custom theme:

Dialog dialog = new Dialog(this, R.style.MyDialogTheme);

Your custom theme needs to fill the screen and disable a couple of Android framework defaults:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyDialogTheme" parent="android:Theme.Dialog">
        <!-- Fill the screen -->
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">fill_parent</item>

        <!-- No backgrounds, titles or window float -->
        <item name="android:windowBackground">@null</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowIsFloating">false</item>      

        <!-- Just to prove it's working -->
        <item name="android:background">#ff0000</item>
    </style>

</resources>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...