android – Custom AlertDialog Borders

android – Custom AlertDialog Borders,第1张

概述我正在创建一个自定义对话框.它的示例代码是: final AlertDialog dialog;protected AlertDialog createDialog(int dialogId) { AlertDialog.Builder builder; builder = new AlertDialog.Builder(parent); AlertDialog fDi 我正在创建一个自定义对话框.它的示例代码是:

final AlertDialog dialog;protected AlertDialog createDialog(int dialogID) {    AlertDialog.Builder builder;    builder = new AlertDialog.Builder(parent);    AlertDialog fDialog = null;    switch(dialogID) {        case Constants.cusDialogtID:            builder = new AlertDialog.Builder(parent);            builder.setTitle("Title");            LayoutInflater inflater = (LayoutInflater)parent.getSystemService(Context.LAYOUT_INFLATER_SERVICE);            VIEw vIEw = inflater.inflate(R.layout.customdialog,null);            builder.setVIEw(vIEw);            fDialog = builder.create();            break;    }    dialog = fDialog;    return dialog;}

问题是,当显示对话框时,它具有原生对话框的灰色背景,其中一些顶部和底部边框也显示在我的自定义对话框中.
有没有办法只显示我的自定义对话框视图…… ???

我使用的XML是:

<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_height="wrap_content"androID:layout_wIDth="fill_parent"androID:orIEntation="vertical"androID:background="@drawable/bgsmall" ><EditText androID:ID="@+ID/redeemamount"androID:layout_wIDth="fill_parent"androID:layout_height="wrap_content" androID:layout_margintop="10dip"androID:layout_marginleft="20dip"androID:layout_marginRight="20dip"androID:hint="Enter amount"androID:inputType="numberDecimal"></EditText>             <button androID:ID="@+ID/submitRedeemAmountbutton"androID:layout_wIDth="fill_parent"androID:layout_height="40dip"androID:text="submit"androID:textcolor="#FFFFFF"androID:textStyle="bold"androID:background="@drawable/buttoncorner"androID:layout_margintop="20dip"androID:layout_marginleft="20dip"androID:layout_marginRight="20dip"androID:layout_marginBottom="20dip"></button></linearLayout>
解决方法 我不认为你可以使用AlertDialog.Builder删除边框.

你可以做的是创建一个扩展Dialog的CustomDialog类,并在CustomDialog的构造函数中为infdialog.xml扩充.

此外,您还需要为对话框创建一个隐藏边框的自定义样式.这是一个例子:

<style      name="CustomStyle"      parent="androID:theme.Dialog">      <item          name="androID:windowBackground">@color/transparent</item>      <item          name="androID:windowContentOverlay">@null</item>    </style>

还要定义透明颜色:

<color      name="transparent">#00000000</color>

您将使用以下命令创建对话框:

CustomDialog dialog=new CustomDialog(this,R.style.CustomStyle);
@H_502_50@ 总结

以上是内存溢出为你收集整理的android – Custom AlertDialog Borders全部内容,希望文章能够帮你解决android – Custom AlertDialog Borders所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1121851.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存