Custom Alertdialog Borders
I am creating a custom dialog. Its example code is: final AlertDialog dialog; protected AlertDialog createDialog(int dialogId) { AlertDialog.Builder builder; builder = new
Solution 1:
I don't think you can remove the borders by using AlertDialog.Builder
.
What you can do is create a CustomDialog
class that extends Dialog
and in the constructor of your CustomDialog
you inflate your customdialog.xml
.
Also you will need to create a custom style
for your dialog, that hides the borders. Here is an example:
<stylename="CustomStyle"parent="android:Theme.Dialog"><itemname="android:windowBackground">@color/transparent</item><itemname="android:windowContentOverlay">@null</item></style>
Also define the transparent color:
<colorname="transparent">#00000000</color>
And you will create your dialog using :
CustomDialog dialog=newCustomDialog(this,R.style.CustomStyle);
Solution 2:
Create a custom theme:
<?xml version="1.0" encoding="utf-8"?><resources><stylename="CustomDialog"parent="android:style/Theme.Dialog"><itemname="android:windowBackground">@null</item></style></resources>
then use it:
builder = new AlertDialog.Builder(parent, R.style.CustomDialog);
Update
The constructor above is indeed API 11+. To work around this you need to extend AlertDialog (since its constructors are protected
) and and then use constructor with theme parameter. To insert your custom view follow the instructions here - the FrameLayout
trick described at the beginning.
Post a Comment for "Custom Alertdialog Borders"