Android DialogFragment如何删除1px边框
我有一个DialogFragment,它在对话框周围显示了一个小的黑色边框(看起来是1像素宽)。我希望我的对话框是平的,没有边框也没有渐变。我怎样才能去掉它 我尝试了以下代码,但没有成功:Android DialogFragment如何删除1px边框,android,android-layout,android-alertdialog,Android,Android Layout,Android Alertdialog,我有一个DialogFragment,它在对话框周围显示了一个小的黑色边框(看起来是1像素宽)。我希望我的对话框是平的,没有边框也没有渐变。我怎样才能去掉它 我尝试了以下代码,但没有成功: public Dialog onCreateDialog(Bundle savedInstanceState) { ... AlertDialog result = builder.create(); result.setView(rootView, 0, 0, 0, 0); result
public Dialog onCreateDialog(Bundle savedInstanceState) {
...
AlertDialog result = builder.create();
result.setView(rootView, 0, 0, 0, 0);
result.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
return result;
//return builder.create();
}
试试这段代码
public class QuickActionFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog m_dialog = new Dialog(QuickActionFragment.this, R.style.Dialog_No_Border);
LayoutInflater m_inflater = LayoutInflater.from(CustomDialogActivity.this);
View v = LayoutInflater.from(mContext).inflate(R.layout.view_quick_action, null, false);
// SET ALL THE VIEWS
m_dialog.setTitle(null);
m_dialog.setContentView(m_view);
m_dialog.show();
return dialog;
}
}
在res/value/style.xml文件中添加对话框\u No\u边框样式
<style name="Dialog_No_Border">
<item name="android:windowIsFloating">true</item>
<item name="android:windowBackground">@color/transparent_color</item>
</style>
真的
@颜色/透明颜色
清理项目,然后运行Thx!它工作得很好。我不得不使用@android:color/transparent而不是@color/transparent\u color