我有一个名为Activity的whereActity
子对话框.现在,我想将此活动显示为另一个活动的对话框.
我怎样才能做到这一点?
我想摆脱对话框中的边框,使其看起来绝对透明,就像图像位于屏幕顶部一样.
我的对话框xml是 -
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<ImageView android:id="@+id/ImageView01"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" android:visibility="invisible"/>
Run Code Online (Sandbox Code Playgroud)
我正在Android Jelly Beans OS上创建一个警告对话框.一切都运作良好,但我想要的是,而不是警报对话框的黑色背景,我想要一个透明的背景.我在stackoverflow上阅读了很多文章和用户的问题,但没有一个能帮助我.
这是我的代码:
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.CustomAlertDialog);
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog1, int which) {
gActivityResult = REQUEST_PICK_CONTACT;
onResume();
return;
} });
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog1, int which) {
return;
} });
View view = getLayoutInflater().inflate(R.layout.alert_dialog, null);
builder.setTitle(R.string.gender_age);
builder.setInverseBackgroundForced(false);
builder.setView (view);
dialog = builder.create ();
Run Code Online (Sandbox Code Playgroud)
这是我的CustomAlertDialog,它在res/values/styles.xml中定义
<style name="CustomAlertDialog" parent="@android:style/Theme.Dialog">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item …
Run Code Online (Sandbox Code Playgroud) android android-layout android-alertdialog android-4.2-jelly-bean
android ×3