无论设备如何,Android 中的完全自定义对话框都具有相同的外观

Fully custom dialog in Android with the same look regardless device(无论设备如何,Android 中的完全自定义对话框都具有相同的外观)
本文介绍了无论设备如何,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));

干杯:):)

这篇关于无论设备如何,Android 中的完全自定义对话框都具有相同的外观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How To Create a Rotating Wheel Control?(如何创建转轮控件?)
How to avoid restarting activity when orientation changes on Android(如何在 Android 上的方向更改时避免重新启动活动)
iOS: How to run a function after Device has Rotated (Swift)(iOS:设备旋转后如何运行函数(Swift))
iOS 8 Rotation Methods Deprecation - Backwards Compatibility(iOS 8 旋转方法弃用 - 向后兼容性)
Screen orientation lock(屏幕方向锁定)
Strange behavior with android orientation sensor(android方向传感器的奇怪行为)