- style文件
<!--全屏对话框-->
<style name="DialogFullWindowStyle" parent="android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
- drawable文件
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/white" />
<corners android:radius="4dp" />
</shape>
- layout布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="320dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
tools:background="#123">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_driverCover"
android:layout_marginTop="-45dp"
android:background="@drawable/rect_background_white"
android:padding="@dimen/size_defaultActivityContentLineMargin">
<TextView
android:id="@+id/tv_driverName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:textColor="@color/color_textOrange"
android:textSize="@dimen/size_textDefault"
tools:text="司机名字" />
<TextView
android:id="@+id/tv_carId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tv_driverName"
android:layout_centerHorizontal="true"
android:layout_marginTop="7dp"
android:textColor="@color/color_defaultTextDarker"
android:textSize="@dimen/size_textDefault"
tools:text="京A88888" />
<TextView
android:id="@+id/tv_driverPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tv_carId"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:layout_marginTop="7dp"
android:textColor="@color/color_defaultTextDark"
android:textSize="@dimen/size_textDefault"
tools:text="18333574728" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="@id/tv_driverPhone"
android:orientation="horizontal">
<Button
android:id="@+id/btn_cancel"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/comm_press_background"
android:gravity="center"
android:text="取消"
android:textSize="@dimen/size_textDefault" />
<Button
android:id="@+id/btn_ok"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/comm_press_background"
android:gravity="center"
android:text="确定"
android:textColor="@color/color_textOrange"
android:textSize="@dimen/size_textDefault" />
</LinearLayout>
</RelativeLayout>
<ImageView
android:id="@+id/iv_driverCover"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:src="@mipmap/default_diver_cover"
tools:background="#123" />
</RelativeLayout>
</RelativeLayout>
- java代码
private void showUserInfoDialog(DriverBean bean) {
Dialog view = new Dialog(this, R.style.DialogFullWindowStyle);// 创建自定义样式dialog
view.setCancelable(false);// 不可以用“返回键”取消
view.setContentView(R.layout.dialog_show_driver_info);// 设置布局
ImageView iv_driverCover = (ImageView) view.findViewById(R.id.iv_driverCover);
TextView tv_driverName = (TextView) view.findViewById(R.id.tv_driverName);
TextView tv_carId = (TextView) view.findViewById(R.id.tv_carId);
TextView tv_driverPhone = (TextView) view.findViewById(R.id.tv_driverPhone);
Button btn_cancel = (Button) view.findViewById(R.id.btn_cancel);
Button btn_ok = (Button) view.findViewById(R.id.btn_ok);
ImageLoader.getInstance().displayImage(bean.getHeadUrl(), iv_driverCover,
ImageLoaderUtils.loadImage(this, cUtils.dp2px(100), R.mipmap.default_diver_cover));
tv_driverName.setText(bean.getName());
tv_carId.setText(bean.getDriverNum());
tv_driverPhone.setText(StringUtils.splitString(bean.getPhone(), "-", StringUtils.SPLIT_TYPE_1));
view.show();
btn_cancel.setOnClickListener(v -> {
view.dismiss();
mQRCodeView.startSpot();
});
btn_ok.setOnClickListener(v -> {
view.dismiss();
OutingRepertoryActivity_.intent(ToScanQRCodeActivity.this).whichPage(OutingRepertoryActivity_.Page_Out).driverBean(bean).start();
animUtils.leftInAnimation(ToScanQRCodeActivity.this);
mQRCodeView.onDestroy();
finish();
});
}