Guy*_*Guy 24 user-interface android android-ui android-activity
我有一个主题为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>
Run Code Online (Sandbox Code Playgroud)
我正试图摆脱它周围的边框和填充..我想填补屏幕的水平.没有灰色边框.请帮忙 :)

Dav*_*unt 80
请务必创建引用自定义主题的Dialog:
Dialog dialog = new Dialog(this, R.style.MyDialogTheme);
Run Code Online (Sandbox Code Playgroud)
您的自定义主题需要填满屏幕并禁用几个Android框架默认值:
<?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>
Run Code Online (Sandbox Code Playgroud)
小智 13
与上面相同但是在代码中而不是在xml中为我工作.
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
Run Code Online (Sandbox Code Playgroud)
设置宽度和高度以匹配父容器.
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;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25514 次 |
| 最近记录: |