【发布时间】:2020-02-24 20:02:23
【问题描述】:
我的 alertdialog 总是将活动布局更改为白页。使用相机时出现对话框。尝试将背景更改为透明但没有运气。有任何想法吗?附上模拟器的截图。希望在使用相机时出现警报对话框,而不是让白色背景覆盖整个屏幕。
代码:
AlertDialog alertDialog = new AlertDialog.Builder(this)
//set icon
.setIcon(android.R.drawable.ic_dialog_alert)
//set title
.setTitle("Kan ikke finne produktet i databasen")
//set message
.setMessage("Vil du søke manuelt?")
// Background
//set positive button
.setPositiveButton("Ja", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent(ScanActivity.this, ManualActivity.class);
startActivity(intent);
}
})
//set negative button
.setNegativeButton("Nei", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent(ScanActivity.this, ScanActivity.class);
startActivity(intent); }
})
.show();
XML
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.journeyapps.barcodescanner.BarcodeView
android:id="@+id/zxing_barcode_surface"
android:layout_height="match_parent"
android:layout_width="match_parent"
app:zxing_framing_rect_width="225dp"
app:zxing_framing_rect_height="275dp"
/>
<com.journeyapps.barcodescanner.ViewfinderView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/zxing_viewfinder_view"
app:zxing_possible_result_points="#FFC300"
app:zxing_viewfinder_laser="#EA1818"
app:zxing_result_view="#2DA818"
app:zxing_viewfinder_mask="@color/zxing_custom_viewfinder_mask"
/>
<TextView
android:id="@+id/zxing_status_view"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_gravity="bottom|center_horizontal"
android:background="@color/zxing_transparent"
android:text="@string/barcode_help"
android:textColor="@color/zxing_status_text"
/>
</merge>
【问题讨论】:
-
你能分享你的活动 xml 文件吗?
-
添加了 xml 布局。
标签: android android-camera android-alertdialog zxing