我有一个主题为Theme.Transparent的活动,它是:
<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>
我在试着摆脱边界和周围的填充物..我想填满屏幕的水平方向。并且没有灰色边框。请帮助:)
发布于 2012-01-16 21:38:59
请确保创建引用自定义主题的对话框:
Dialog dialog = new Dialog(this, R.style.MyDialogTheme);
您的自定义主题需要填满屏幕并禁用几个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>
发布于 2014-05-14 02:34:58
和上面的一样,但是在代码中而不是在xml中工作对我很有效。
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
发布于 2015-12-02 14:59:41
设置宽度和高度以匹配父容器。
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
WindowManager.LayoutParams wmlp = dialog.getWindow()
.getAttributes();
wmlp.width = android.view.WindowManager.LayoutParams.MATCH_PARENT;
wmlp.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT;
https://stackoverflow.com/questions/8836938
复制相似问题