DialogFragment使用
2017-04-12 17:34
260 查看
1.布局中设置padding 如何不设置会被覆盖无法显示圆角
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { //去掉标题 getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE); //设置背景 圆角 getDialog().getWindow().setBackgroundDrawableResource(R.drawable.background); View view = inflater.inflate(R.layout.news_webview, container, false); WebView news_webview= (WebView) view.findViewById(R.id.news_webview); news_webview.getSettings().setJavaScriptEnabled(true); news_webview.loadUrl(loadUrl); return view; } @Override public void onStart() { super.onStart(); Dialog dialog=getDialog(); if (dialog!=null){ /** * 设置dialog的大小 */ DisplayMetrics dm = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); dialog.getWindow().setLayout((int) (dm.widthPixels * 0.6), (int) (dm.heightPixels*0.7)); } } <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="10dp"></corners> <solid android:color="@color/white"></solid> </shape>
布局
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:padding="5dp" android:layout_height="match_parent"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <WebView android:padding="@dimen/margin15" android:id="@+id/news_webview" android:layout_width="match_parent" android:background="@color/white" android:layout_height="match_parent"></WebView> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/set" android:layout_marginTop="0dp" android:layout_marginRight="0dp" android:layout_alignRight="@+id/news_webview" android:layout_alignParentRight="true"/> </RelativeLayout> </RelativeLayout>
相关文章推荐
- android 使用DialogFragment 自定义Dialog
- 使用DialogFragment创建对话框总结
- DialogFragment的相关使用
- Android使用DialogFragment,自定义对话框
- seekbar +DialogFragment 简单使用
- android DialogFragment使用 附例子
- Android使用DialogFragment创建对话框
- Fragment中使用DatePickerDialog、TimePickerDialog
- Android官方推荐使用DialogFragment替换AlertDialog
- DialogFragment的使用方法简介
- Android:DialogFragment的使用
- android DialogFragment简单使用
- Android 屏幕旋转(方向和configChanges) 处理 AsyncTask 和 ProgressDialog 的最佳方案(DialogFragment 使用 续)
- support.v4.app.DialogFragment使用问题总结
- Using DialogFragment ——使用DialogFragment
- 使用DialogFragment
- ApiDemos--DialogFragment的使用
- Android 使用DialogFragment 对话框实现
- DialogFragment和ListFragment使用
- Android-----DialogFragment的使用