問題描述
無論操作系統(tǒng)主題如何,我都必須構(gòu)建一個在不同設(shè)備上看起來完全相同的對話框.目前,我創(chuàng)建了一個 AlertDialog
并調(diào)用 alertDialog.setView(myLayout)
.這將創(chuàng)建一個包含我的視圖的對話框.但是,對話框的某些部分(外部和邊界線)仍然是基于操作系統(tǒng)的,它們在我的三星或 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.
有沒有辦法創(chuàng)建實際的盒子?
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));
干杯:):)
這篇關(guān)于無論設(shè)備如何,Android 中的完全自定義對話框都具有相同的外觀的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!