Android Center Crop Image Not working on device but working in Eclipse -
i have list view image background each list item. trying set src downloading image given url. need center crop imageview view image occupies entire screen (width , height).
this xml list item:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/list_item" android:layout_width="match_parent" android:layout_height="match_parent" > <imageview android:id="@+id/img_askers_collage" android:layout_width="match_parent" android:layout_height="match_parent" android:adjustviewbounds="true" android:scaletype="centercrop"/> <linearlayout android:id="@+id/ll_question_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerinparent="true" android:layout_marginbottom="40dp" android:layout_margintop="50dp" android:gravity="center" android:orientation="vertical" > <me.frankly.view.bariolboldtextview android:id="@+id/question_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="5dp" android:layout_marginleft="@dimen/activity_horizontal_margin" android:layout_marginright="@dimen/activity_horizontal_margin" android:gravity="center" android:textcolor="@color/white_pure" android:textsize="22sp" /> <relativelayout android:id="@+id/author_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="10dp" > <me.frankly.view.barioltextview android:id="@+id/leading_text_author" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/leading_text_author" android:textcolor="@color/white_pure" android:textsize="17sp" /> <me.frankly.view.barioltextview android:id="@+id/question_author_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_torightof="@id/leading_text_author" android:paddingleft="5dp" android:textcolor="@color/comment_username" android:textsize="17sp" /> </relativelayout> </linearlayout> </relativelayout>
this main activity layout:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/default_background" > <include android:id="@+id/answer_question_action_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparenttop="true" layout="@layout/action_bar_backbtn_text" /> <view android:id="@+id/view_answer_question" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignbottom="@id/answer_question_action_bar" android:layout_aligntop="@id/answer_question_action_bar" > </view> <listview android:id="@+id/asked_question_list" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@id/view_answer_question" android:cachecolorhint="#00000000" android:divider="@null" android:dividerheight="0dp" > </listview> </relativelayout>
and snippet sets image inside getview of adapter, imageloader uil:
imageloader.getinstance().loadimage(askerscollageurl, new imageloadinglistener() { @override public void onloadingcomplete(string arg0, view arg1, bitmap arg2) { if (holder.askerscollageurl.equals(arg0)) { drawable d = new bitmapdrawable(mcontext.getresources(), arg2); holder.collageimageview.setimagedrawable(d) ; } } //omitting other methods heere });
this expected:
this get:
hi make function crop image
private void performcrop(uri imageuri) { try { // call standard crop action intent (the user device may not // support it) intent cropintent = new intent("com.android.camera.action.crop"); // indicate image type , uri cropintent.setdataandtype(imageuri, "image/*"); // set crop properties cropintent.putextra("crop", "true"); // indicate aspect of desired crop cropintent.putextra("aspectx", 1); cropintent.putextra("aspecty", 1); // indicate output x , y if (act.equals("registeractivity")) { cropintent.putextra("outputx", 71); cropintent.putextra("outputy", 58); } else if (act.equals("changeprofileactivity")) { cropintent.putextra("outputx", 242); cropintent.putextra("outputy", 142); } else if (act.equals("changeprofilepicactivity")) { cropintent.putextra("outputx", 242); cropintent.putextra("outputy", 328); } // retrieve data on return cropintent.putextra("return-data", true); // start activity - handle returning in onactivityresult startactivityforresult(cropintent, pic_crop); } catch (activitynotfoundexception anfe) { // display error message string errormessage = "whoops - device doesn't support crop action!"; toast toast = toast .maketext(this, errormessage, toast.length_short); toast.show(); } }
Comments
Post a Comment