WEB开发网
开发学院手机开发Android 开发 Android 开发 怎样使当前界面的背景透明 阅读

Android 开发 怎样使当前界面的背景透明

 2010-02-27 04:50:00 来源:WEB开发网   
核心提示:activity的代码如下:view plaincopy to clipboardprint?1. public class StartActivity extends Activity {2. public void onCreate(Bundle savedInstanceState){3. super.onCre

activity的代码如下:

view plaincopy to clipboardprint?

1. public class StartActivity extends Activity {

2. public void onCreate(Bundle savedInstanceState){

3. super.onCreate(savedInstanceState);

4. showDialog(1);

5. }

6.

7. protected Dialog onCreateDialog(int id) {

8. LayoutInflater factory = LayoutInflater.from(this);

9. View tv = factory.inflate(R.layout.login,null);

10. return new AlertDialog.Builder(this).setTitle("请输入验证码:").setPositiveButton("确定",new DialogInterface.OnClickListener() {

11. public void onClick(DialogInterface dialog, int which) {

12. Intent i = new Intent(StartActivity.this,MainTab.class);

13. StartActivity.this.startActivity(i);

14. finish();

15. }

16. }).setView(tv).create();

17. }

18. }

public class StartActivity extends Activity { public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); showDialog(1); } protected Dialog onCreateDialog(int id) { LayoutInflater factory = LayoutInflater.from(this); View tv = factory.inflate(R.layout.login,null); return new AlertDialog.Builder(this).setTitle("请输入验证码:").setPositiveButton("确定",new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent i = new Intent(StartActivity.this,MainTab.class); StartActivity.this.startActivity(i); finish(); } }).setView(tv).create(); } }

很简单的代码,就是显示一个对话框

如果直接运行,会看到背景为黑色的,如果想要透明背景的话,需要对当前的activity加上一个主题,即透明主题,修改AndroidManifest.xml

中的activity的定义:

view plaincopy to clipboardprint?

  1.        <activity 
  2. android:name=".StartActivity" 

1 2  下一页

Tags:Android 开发 怎样

编辑录入:coldstar [复制链接] [打 印]
赞助商链接