android - My layout is crashed after Picasso loads images [UPDATED] -


i'm trying build customized image layout looks following, 4 a's indicate 1 imageview.

aabc aade 

when tried draw layout default src attributes, or when put placeholder options on picasso, layout rendered without problem. however, while picasso gradually lazy-loads each image, layout crashed this. (the space below a blank space.)

abc  de 

how can maintain original layout picasso's lazy loading? customsquareimageview custom class extends imageview draw squared imageview.

partoflayout.xml

<linearlayout     android:id="@+id/set_profile_profile_photos_layout"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:baselinealigned="false">      <linearlayout         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_weight="1"         android:orientation="horizontal">          <customsquareimageview             android:id="@+id/set_profile_profile_photos_first"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:scaletype="centercrop"             android:src="@drawable/profile" />      </linearlayout>      <linearlayout         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_weight="1"         android:orientation="vertical">          <linearlayout             android:layout_width="wrap_content"             android:layout_height="wrap_content">              <customsquareimageview                 android:id="@+id/set_profile_profile_photos_second"                 android:layout_width="0dp"                 android:layout_height="wrap_content"                 android:layout_weight="1"                 android:scaletype="centercrop"                 android:src="@drawable/profile" />              <customsquareimageview                 android:id="@+id/set_profile_profile_photos_third"                 android:layout_width="0dp"                 android:layout_height="wrap_content"                 android:layout_weight="1"                 android:scaletype="centercrop"                 android:src="@drawable/profile" />          </linearlayout>          <linearlayout             android:layout_width="wrap_content"             android:layout_height="wrap_content">              <customsquareimageview                 android:id="@+id/set_profile_profile_photos_fourth"                 android:layout_width="0dp"                 android:layout_height="wrap_content"                 android:layout_weight="1"                 android:scaletype="centercrop"                 android:src="@drawable/profile" />              <customsquareimageview                 android:id="@+id/set_profile_profile_photos_fifth"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_weight="1"                 android:scaletype="centercrop"                 android:src="@drawable/profile" />          </linearlayout>      </linearlayout>  </linearlayout> 

partoffragment.java

@override public void onviewcreated(view view, @nullable bundle savedinstancestate) {     super.onviewcreated(view, savedinstancestate);     try {         jsonarray profilephotos = new jsonarray(mprofile.getprofileimages());         if (!profilephotos.get(0).tostring().isempty()) {             picasso.with(getactivity()).load(profilephotos.get(0).tostring()).                     placeholder(r.drawable.profile).into(mprofilephotofirst);         }     } catch (jsonexception e) {          e.printstacktrace();     } } 

updated

the answer author here using .fit().centercrop() placeholder solve problem "in end", in process picasso loading images, layout temporarily crashed because each image in different sizes. (after loads image successfully, layout looks good.)

how can load images without crashing layout in middle? want loaded images not disturb layout inserted directly layout centercrop state.

because used linearlayouts image frame, had set layout_width of linearlayouts match_parent, not wrap_content or 0dp android studio suggested.

my new xml looks this.

newpartoflayout.xml

<linearlayout     android:id="@+id/set_profile_profile_photos_layout"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:baselinealigned="false">      <linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_weight="1"         android:orientation="horizontal">          <customsquareimageview             android:id="@+id/set_profile_profile_photos_first"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:scaletype="centercrop"             android:src="@drawable/profile" />      </linearlayout>      <linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_weight="1"         android:orientation="vertical">          <linearlayout             android:layout_width="match_parent"             android:layout_height="wrap_content">              <customsquareimageview                 android:id="@+id/set_profile_profile_photos_second"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:layout_weight="1"                 android:scaletype="centercrop"                 android:src="@drawable/profile" />              <customsquareimageview                 android:id="@+id/set_profile_profile_photos_third"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:layout_weight="1"                 android:scaletype="centercrop"                 android:src="@drawable/profile" />          </linearlayout>          <linearlayout             android:layout_width="match_parent"             android:layout_height="wrap_content">              <customsquareimageview                 android:id="@+id/set_profile_profile_photos_fourth"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:layout_weight="1"                 android:scaletype="centercrop"                 android:src="@drawable/profile" />              <customsquareimageview                 android:id="@+id/set_profile_profile_photos_fifth"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:layout_weight="1"                 android:scaletype="centercrop"                 android:src="@drawable/profile" />          </linearlayout>      </linearlayout>  </linearlayout> 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -