Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
454 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 Reply

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...