dialog_border.xml:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.delegate = self;
}
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
}
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
return NO;
}
在我的自定义对话框布局中,我将背景设置为<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white"/>
<stroke android:color="@color/yellow"
android:width="5dp"/>
<padding android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp"/>
<corners android:radius="25dp"/>
android:background="@drawable/dialog_border"
答案 0 :(得分:0)
我建议你在你正在使用的布局文件中绘制形状。在启动时使用isVisible="gone"
。然后,当您想要显示对话框时,您只需显示它所在的布局。 Button.onClickListener应该只是再次隐藏布局。
类似的东西:
<MainLayout>
...
<LinearLayout id="@+id/toHide" visibility="gone">
<EditText>
<Button id="@+id/closeDialog">
</LinearLayout>
...
</MainLayout>
布局文件中的。然后在你的java文件中:
LinearLayout toHide = (LinearLayout) findViewById(R.id.toHide);
Button btn = (Button) findViewById(R.id.closeDialog);
btn.setOnClickListener( ... toHide.setVisibility(GONE); ...)
加:
toHide.setVisibility(VISIBLE)
当您显示对话框时
答案 1 :(得分:0)
THEME_DEVICE_DEFAULT_LIGHT可能具有覆盖透明色的背景色调。尝试使用像这样的自定义样式:
<style name="CustomDialog" parent="android:Theme.Dialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>