android - Setting Margins for EditText in AlertDialog -


i've created alertdialog edittext in android app, default margins off. i've tried specify margins follows:

  android.support.v7.app.alertdialog.builder builder =  new android.support.v7.app.alertdialog.builder(spinactivity.this);             builder.settitle("edit spin tags");             builder.setmessage("(separate tags commas)");              // set input             int margin = 10;             final edittext input = new edittext(spinactivity.this);             input.setsingleline();             input.settext(spintags.tostring().replace("[", "").replace("]", ""));             builder.setview(input, margin, 0, margin, 0); 

however, image below, can see not applying desired effect.

enter image description here

other options i've tried including placing input in linearlayout , setting margins using layoutparams before setting alertdialog view linearlayout.

how set margins edittext in alertdialog?

actually solution working perfectly, except builder.setview(input, margin, 0, margin, 0); takes arguments in "pixel" values. value of 20 small. either use higher value margin e.g. in 100s. or use function convert dp pixels

public static int dptopx(int dp) {     return (int) (dp * resources.getsystem().getdisplaymetrics().density); } 

and then,

int margin = dptopx(20); 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -