Android 相框宽度
我正在使用dialogFragment创建自己的自定义片段,但其大小与priview中的不一样Android 相框宽度,android,dialogfragment,Android,Dialogfragment,我正在使用dialogFragment创建自己的自定义片段,但其大小与priview中的不一样 这是预览中显示的内容 显示对话框时会发生这种情况 我希望它看起来和我的预览版一模一样-我该怎么办?试试这个 final Dialog dialog = new Dialog(mContext, R.style.Theme_Transparent); View view = LayoutInflater.from(mContext)
这是预览中显示的内容 显示对话框时会发生这种情况 我希望它看起来和我的预览版一模一样-我该怎么办?试试这个
final Dialog dialog = new Dialog(mContext, R.style.Theme_Transparent);
View view = LayoutInflater.from(mContext)
.inflate(R.layout.layout_custom_dialog, null);
dialog.setContentView(view);
Window window = dialog.getWindow();
WindowManager.LayoutParams wlp = window.getAttributes();
wlp.width = wlp.MATCH_PARENT;
wlp.gravity = Gravity.TOP;
wlp.flags &= ~WindowManager.LayoutParams.FLAG_BLUR_BEHIND;
window.setAttributes(wlp);
并将其添加到styles.xml
文件中
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
真的
@android:彩色/透明
@空的
真的
真的
真的