[Android 界面] Android Dialog 在模拟器大屏幕中的半透明背景

先贴我的代码:

MainActivity.java

package com.example.progressbardialog;

 

import android.app.Activity;

import android.app.AlertDialog;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

 

public class MainActivity extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

((Button) this.findViewById(R.id.alertDialog))

.setOnClickListener(new OnClickListener() {

 

@Override

public void onClick(View v) {

new AlertDialog.Builder(MainActivity.this)

.setTitle("Simple Test")

.setMessage("Simple Test").create().show();

}

});

}

}

 

在这个Activity中,只有一个按钮的点击事件,没有其它的任何作用。这个Activity所对应的布局文件如下:

main_activity.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#FFF"

tools:context=".MainActivity" >

 

<Button

android:id="@+id/alertDialog"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="AlertDialog"/>

 

</RelativeLayout>

 

但是结果不尽如人意:他的效果如下所示:

 

但是他在小屏幕中是正确显示的如下图所示:

 

 

研究了好久,没有找到解决办法。

 

如果哪位大大知道,请不令赐教,本人邮箱:lovecluo@nightweaver.org

 

posted on 2013-12-26 20:54  knero  阅读(480)  评论(0)    收藏  举报

导航