Reputation: 2064
I need a way to remove that 2px grey border added by Android to the view content of a dialog. I've tried most of the solution marked as OK on this site. Desired final result is presented in the last image (a dialog showing just my view, without any additional UI elements added by android)
This is current code:
AlertDialog.Builder builder = new Builder(this);
builder.setView(dialogContent); //a view inflated from xml
...
chooseActionDialog = builder.create();
...
chooseActionDialog.setView(dialogContent, 0, 0, 0, 0); //this removed the padding between grey border & actual content.. this is why i set view twice
chooseActionDialog.show();
...
Drawable d = new ColorDrawable(Color.TRANSPARENT);
chooseActionDialog.getWindow().setBackgroundDrawable(d); //this seems to change color of padding area (between grey border & actual content)
Note: the Builder contructor with 2 params (context, themeId) doenst work as expected (still have border & dialog gets streched ugly)
Upvotes: 0
Views: 883
Reputation: 1124
Create ur own style in your style.xml in values folder like below
<style name="Theme.Trans" parent="android:Theme.Translucent">
<item name="android:windowFrame">@null</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowTitleStyle">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:background">@android:color/transparent</item>
</style>
apply this style to your dialog
final Dialog dialog = new Dialog(UrActivity.this, R.style.Theme_Trans);
Upvotes: 3