android - How to use full Width of the screen using AlertDialog -


i want use full width of screen show dialog , image inside that...

i have written custom xml file show alert dialog , have posted complete code using show image sdcard dialog.

code:

holder.viewimagebutton.setonclicklistener(new onclicklistener() {      @override     public void onclick(view vi) {                final alertdialog.builder imagedialog = new alertdialog.builder(uploadactivity.this);         final layoutinflater inflater = (layoutinflater)                            getapplicationcontext().getsystemservice(layout_inflater_service);          view layout = inflater.inflate(r.layout.custom_fullimage_dialog,          (viewgroup) findviewbyid(r.id.layout_root));          imageview image = (imageview) layout.findviewbyid(r.id.fullimage);          try         {            filename = imagelist.get(position).tostring().             substring(strpath.lastindexof('/')+1, strpath.length());              string filetoview = environment.getexternalstoragedirectory().getpath() + "/pictures/joseph/" + cameralauncheractivity.folder+ "/" + filename;             log.d("filetodelete", filetoview);              // image             newfile = new file(filetoview); // related file on click             // set image             image.setimageuri(uri.fromfile(newfile));                     } catch (exception e) {                  // when error                 e.printstacktrace();             image.setimageresource(r.drawable.fail);         }                                // name         filename=imagelist.get(position).tostring().substring             (strpath.lastindexof('_')+1, strpath.length());         imagedialog.settitle(filename);         imagedialog.setview(layout);         imagedialog.setpositivebutton(android.r.string.ok, new              dialoginterface.onclicklistener(){          public void onclick(dialoginterface dialog, int which) {         // dismiss dialog                 dialog.dismiss();             }                             });               imagedialog.create();         imagedialog.show();        }   }); 

custom_fullimage_dialog.xml:-

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/layout_root"         android:orientation="horizontal"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:weightsum="3"         android:gravity="center">      <imageview         android:id="@+id/fullimage"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:contentdescription="@null" />      <textview         android:id="@+id/custom_fullimage_placename"         android:layout_width="wrap_content"         android:layout_height="fill_parent"         android:textcolor="#fff" >     </textview>  </linearlayout> 

you can set attributes windowmanager. can try that:

    dialog dialog = new dialog(getactivity());     dialog.requestwindowfeature(window.feature_no_title);     dialog.setcontentview(r.layout.dialog_custom);     dialog.getwindow().setbackgrounddrawable(getresources().getdrawable(r.drawable.background)); // optional background     dialog.setcanceledontouchoutside(true);     dialog.setcancelable(true);     windowmanager.layoutparams lp = new windowmanager.layoutparams();     lp.copyfrom(dialog.getwindow().getattributes());     lp.width = windowmanager.layoutparams.match_parent;     lp.height = windowmanager.layoutparams.match_parent;          // stuff         // dialog.findviewbyid(.....)      dialog.show();     dialog.getwindow().setattributes(lp); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -