2013-12-21 35 views
0

enter image description hereAndroid:如何从AlertDialog中删除矩形的角?

我尝试这样做:

AlertDialog.Builder alertSeverity = new AlertDialog.Builder(getActivity(), android.R.style.Theme_Translucent_NoTitleBar); 

,但它说, 调用API需要11级(当前min的8):新android.app.AlertDialog.Builder

我发现其他方法也如定义形状

<shape android:shape="rectangle"> 
    <solid android:color="#FFFFFF" /> 
    <corners android:topLeftRadius="5dp" android:topRightRadius="5dp" /> 
    <stroke android:color="#FFFFFF" android:width="1dp" /> 
</shape> 

但我不知道什么半径我的角是金属G。是的,我可以做出假设和所有。但我只是问有没有简单的方法来做到这一点?

+0

采用Android定制alertdialog建设者 –

+0

在developer.android它说,使用DialogFragment来做到这一点 但呼叫要求API级别11(当前最低为8):新的android.app.DialogFragment:/ –

+0

你可以发布新的快照吗? –

回答

0

得到了解决..

final Dialog dialog = new Dialog(context, R.style.CustomDialogTheme); 
dialog.setContentView(R.layout.exitview); 

Button yes_button = (Button) dialog.findViewById(R.id.yes); 
yes_button.setOnClickListener(this); 

Button no_button = (Button) dialog.findViewById(R.id.no); 
no_button.setOnClickListener(this); 

dialog.show(); 
风格

,和上面一样,

<style name="CustomDialogTheme" parent="@android:style/Theme.Dialog"> 
    <item name="android:windowBackground">@android:color/transparent</item> 
    <item name="android:windowIsFloating">false</item> 
    <item name="android:windowNoTitle">true</item> 
</style> 
0

创建以下的风格将它设置为你的对话框的背景

<style name="CustomDialogTheme" parent="@android:style/Theme.Dialog"> 
     <item name="android:windowBackground">@android:color/transparent</item> 
     <item name="android:windowIsFloating">false</item> 
     <item name="android:windowNoTitle">true</item> 
</style> 

对于前:

AlertDialog.Builder alertSeverity = new AlertDialog.Builder(getActivity(), R.style.CustomDialogTheme); 

这里windowBackground是从对话框中删除边框的关键。

编辑

试试这个:

AlertDialog.Builder alertSeverity =new AlertDialog.Builder(
    new ContextThemeWrapper(getActivity(), R.style.CustomDialogTheme)); 
+0

我讨厌这么说,但是,Call需要API等级11(当前最小为8):new android.app.AlertDialog.Builder。它只是在杀我。没有任何工作。 –

+0

试试我的编辑ans –

+0

好吧,它的工作原理,我的意思是没有错误。但它仍然有圆角。 :( 我认为我的@android:颜色/透明有一些问题左右 –