android - spacing of items added to linear layout changes -


i adding pictures linearlayout programmatically. linearlayout surrounded horizontalscrollview , part of item layout listview. when have pictures inline other view items, spaced next eachother correctly: enter image description here

however if move horizontalscrollview/linearlayout under other view items, weird spacing android seems automatically: enter image description here

so far have tried relativelayouts, embedded linearlayouts, changing padding, changing margins, changing width property of linearlayout between match_parent, fill_parent, , wrap_content, nothing changes spacing. same.

here relevant code:

linearlayout tmpll = (linearlayout) convertview.findviewbyid(r.id.llupgrades);          //remove previous list contents first         tmpll.removeallviews();          for(int = 0; i<= tmpupgradelist.size()-1; i++){              imageview tmpib = new imageview(getcontext());             upgrade tmpupgrade = tmpupgradelist.get(i);             upgrade.setupgradepic(tmpib, tmpupgrade, tmpupgrade.title()==null);             tmpib.settag(position + ":" + i);             tmpib.setpadding(5, 0, 0, 0);             tmpib.setmaxwidth(50);              tmpll.addview(tmpib);              tmpib.setonclicklistener(new view.onclicklistener() {                 @override                 public void onclick(view v) {                       string[] split = ((string) v.gettag()).split(":");                      runupgradepopup(integer.parseint(split[0]), integer.parseint(split[1]));                 }             });              tmpib.setonlongclicklistener(new view.onlongclicklistener() {                 @override                 public boolean onlongclick(view v) {                      string[] split = ((string) v.gettag()).split(":");                      clearupgrade(integer.parseint(split[0]), integer.parseint(split[1]));                      return true;                 }             });          } 

layout of 1 causing error. other layout puts cards next each other correctly have different is linear layout , removed relevant relative placement calls:

<relativelayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="vertical"     android:paddingtop="5dp"     android:paddingbottom="5dp">           <button             android:layout_width="100dp"             android:layout_height="60dp"             android:id="@+id/btnfremoveship"             android:text="remove"/>          <imageview             android:id="@+id/ivfrowshipicon"             android:layout_height="60dp"             android:layout_width="75dp"             android:src="@android:drawable/ic_delete"             android:layout_marginleft="10dp"             android:layout_torightof="@+id/btnfremoveship"/>           <textview             android:layout_height="wrap_content"             android:ems="10"             android:layout_width="wrap_content"             android:id="@+id/tvfrowshiptitle"             android:text="error"             android:textsize="20dp"             android:layout_marginleft="10dp"             android:layout_torightof="@+id/ivfrowshipicon"/>            <horizontalscrollview             android:orientation="horizontal"             android:layout_width="match_parent"             android:layout_height="75dp"             android:layout_margintop="5dp"             android:layout_below="@+id/btnfremoveship">              <linearlayout                 android:orientation="horizontal"                 android:layout_width="fill_parent"                 android:layout_height="fill_parent"                 android:id="@+id/llupgrades">             </linearlayout>         </horizontalscrollview>   </relativelayout> 

any appreciated!

took couple days of rewording question found answer. had add line before adding image layout.

tmpib.setadjustviewbounds(true); 

thread here: found answer


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -