Why am i getting this white background under my alert dialogbox. I been trying to figure out the problem for an hour and had no luck. Can someone please help me?
Also, why is that the left and right sides of the title has a little dark shade.
protected void onPostExecute(String result) {
//progressDialog.dismiss();
try {
JSONObject json = new JSONObject(result);
String status = json.getString("status");
String message = json.getString("message");
if(status.equals("true")) {
Intent intent = new Intent(context, HomeActivity.class);
intent.putExtra(LoginActivity.EXTRA_MESSAGE, status);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
else{
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setMessage(message)
.setTitle("Error")
.setNeutralButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
}).create().show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
setBackgroundColor(Color. TRANSPARENT); wv. setPadding(5, 25, 5, 0); ImageView imgcartl=(ImageView)layout.
on your dialog builder. It will force the background to white color (instead of dark grey) on android version before Froyo.
Import android.support.v7.app.AlertDialog instead of android.app.AlertDialog
Change your code as -
Dialog alertDialog = new Dialog(this);
alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
alertDialog.setContentView(R.layout.tabs);
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
alertDialog.show();
Or you can add theme to your existing code.
AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
When initializing dialog builder, pass second parameter as the theme. So Change
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
to
AlertDialog.Builder builder = new AlertDialog.Builder(activity, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
It is old answer, now
Import android.support.v7.app.AlertDialog
instead of android.app.AlertDialog
as given in accepted answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With