Android 显示带有全屏图像的对话框只占屏幕的80%
我想全屏显示一幅图像,然后在用户按下时关闭它 我使用的是一个对话框,它占据了大约80%的屏幕。在我的图像周围有一个白色边框(它不在我的文件系统中) 如何使此对话框完全全屏显示Android 显示带有全屏图像的对话框只占屏幕的80%,android,dialog,viewgroup,layoutparams,Android,Dialog,Viewgroup,Layoutparams,我想全屏显示一幅图像,然后在用户按下时关闭它 我使用的是一个对话框,它占据了大约80%的屏幕。在我的图像周围有一个白色边框(它不在我的文件系统中) 如何使此对话框完全全屏显示 SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); boolean viewedInstructions = sharedPreferences.getBoolean("inst
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean viewedInstructions = sharedPreferences.getBoolean("instructions_viewed", false);
if (!viewedInstructions) {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean("instructions_viewed", true);
editor.commit();
final Dialog d = new Dialog(this);
d.requestWindowFeature(Window.FEATURE_NO_TITLE);
d.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
d.setContentView(R.layout.instructions_dialog);
d.findViewById(R.id.tutorial).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
d.dismiss();
}
});
d.show();
布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/dialog_layout_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="vertical"
android:padding="10dp"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tutorial"
android:src="@drawable/dashboard_instructions"/>
</LinearLayout>
试试这个:
final Dialog d = new Dialog(this,R.style.MyDialogStyle);
并在styles.xml中定义此样式:
<!-- Animation for dialog box -->
<style name="MyDialogStyle" parent="@android:style/Theme.Translucent.NoTitleBar">
</style>
您还可以在清单中定义它,为活动设置它:
<activity
android:name="com.example.YourActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
</activity>
尝试更改此行
final Dialog d = new Dialog(this);
与
您是否尝试使用@android:style/Theme.Translucent.NoTitleBar作为您的对话框样式?我如何更改对话框的主题?我将其标记为接受,这很好,但不会超出最大值屏幕仍有白色边框,但比我的更好。您仍然可以更改对话框的背景色,但您必须使用如下背景标签来放大布局:android:background=“@android:color/background\u dark”>
final Dialog d = new Dialog(this, android.R.style.Theme_Black_NoTitleBar_Fullscreen);