11
A
回答
5
以下用于Android C#代码的Mono可以做到这一点(但应该很容易移植到Java)。我测试了Android 2.2(Galaxy S)和Android 4.1(Nexus 7)。唯一需要更改的是用于父视图和对话视图的布局ID。
[Activity (MainLauncher = true)]
public class TestCustomDialogActivity : FragmentActivity
{
public class MyDialogFragment : Android.Support.V4.App.DialogFragment
{
public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
// Android 3.x+ still wants to show title: disable
Dialog.Window.RequestFeature(WindowFeatures.NoTitle);
// CHANGE TO YOUR DIALOG LAYOUT or VIEW CREATION CODE
return inflater.Inflate(Resource.Layout.MyLayout, container, true);
}
public override void OnResume()
{
// Auto size the dialog based on it's contents
Dialog.Window.SetLayout(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent);
// Make sure there is no background behind our view
Dialog.Window.SetBackgroundDrawable(new ColorDrawable(Color.Transparent));
// Disable standard dialog styling/frame/theme: our custom view should create full UI
SetStyle(Android.Support.V4.App.DialogFragment.StyleNoFrame, Android.Resource.Style.Theme);
base.OnResume();
}
}
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// CHANGE TO YOUR MAIN SCREEN
SetContentView(Resource.Layout.MyDialog);
var dialog = new MyDialogFragment();
dialog.Show(SupportFragmentManager, "dialog");
}
}
我上传了一个完整的Mono的Android样品https://github.com/t9mike/CustomDialogFragmentSample。下面
23
代码将帮助你全屏显示对话框,它还设置透明色
Dialog dialog = new Dialog(this);
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
// layout to display
dialog.setContentView(R.layout.about_program_dialog_layout);
// set color transpartent
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();
about_program_dialog_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#55000000" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="227dp"
android:text="Dismiss" />
<TextView
android:id="@+id/autoCompleteTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/button1"
android:layout_alignParentRight="true"
android:layout_marginBottom="16dp"
android:layout_marginRight="63dp"
android:ems="10"
android:text="Hello There World" />
</RelativeLayout>
+2
这是一个对话框,而不是DialogFragment,如同在问题中 –
相关问题
- 1. 如何创建自定义对话框
- 2. 片段中的自定义对话框
- 3. 如何在自定义对话框中创建幻灯片?
- 4. 在创建对话框片段时忽略对话框片段
- 5. 创建自定义jframe对话框
- 6. 创建自定义对话框
- 7. 试图创建自定义对话框
- 8. 以mfc创建自定义对话框
- 9. 创建自定义图像的Android对话片段它上面
- 10. 重用片段以创建对话框
- 11. 如何使用自定义列表视图创建自定义对话框
- 12. 如何在JavaFX中使用FXML创建自定义对话框?
- 13. Gmail如何创建此自定义提示对话框?
- 14. 如何在CRM 2011中创建自定义HTML对话框
- 15. 如何创建自定义的Facebook对话框的“涂鸦墙”
- 16. 如何用cocos2d创建自定义对话框?
- 17. 如何在installanywhere中创建自定义对话框?
- 18. 如何在InstallShield中创建自定义对话框?
- 19. 如何在创建之前杀死自定义对话框?
- 20. 如何创建我的jQuery UI自定义对话框?
- 21. 如何创建不带窗口的自定义对话框
- 22. 如何在android中创建自定义对话框标题?
- 23. 如何在vscode中创建自定义对话框?
- 24. 如何在Android中创建自定义共享对话框
- 25. 如何在wix自定义对话框中创建选项卡?
- 26. Android-如何创建自定义对话框/提醒
- 27. 如何创建完全自定义的警报对话框?
- 28. 如何在LiveCode中创建自定义对话框
- 29. 如何创建自定义安装遮罩对话框皮肤?
- 30. 在对话框片段中更改自定义对话框的高度
感谢。一旦转换为Java,这对我来说就是诀窍。我必须将WRAP_CONTENT更改为MATCH_PARENT才能使对话框全屏显示。 – speedynomads
感谢Github上传 – Signcodeindie