完全在Android的定制对话框具有相同的外观,无论设备 [英] Fully custom dialog in Android with the same look regardless device

查看:129
本文介绍了完全在Android的定制对话框具有相同的外观,无论设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建立一个对​​话框,看起来完全在不同设备上的一样的,不管操作系统的主题。此刻,我创建了一个 AlertDialog ,我称之为 alertDialog.setView(myLayout)。这将创建我的观点的对话框。但是,对话框(外部分和边框线)的某些部分仍然是基于操作系统的,他们看在我的三星和HTC不同。

I have to build a dialog that looks exactly the same across different devices regardless of the OS theme. At the moment, I created an AlertDialog and I call alertDialog.setView(myLayout). This creates a dialog with my view. However, some parts of the dialog box (outer part and border line) are still OS based and they look different in my Samsung or HTC.

反正是有创建实际的盒子?

Is there anyway to create the actual box?

推荐答案

去为这个

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;

public class FullyscutomDialo extends Dialog{

public FullyscutomDialo(Context context) {
    super(context);
    // TODO Auto-generated constructor stub
}

@Override
public void dismiss() {
    //do what you need before closing here
    super.dismiss();
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //set your custom layout here
    //use layout attribut just like activity
}

 }

然后用两行从活动表现出来(可能是onclickevent等)

then use two line to show it from activity(May be onclickevent etc)

         FullyscutomDialo hh=new FullyscutomDialo (this);
         hh.show()

编辑以透明的对话

使用在对话框类的onCreate

use In onCreate of dialog class

 this.getWindow().setBackgroundDrawable(new ColorDrawable(0));

干杯:):)

Cheers :):)

这篇关于完全在Android的定制对话框具有相同的外观,无论设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆