android - how to control ImageView Gravity Dynamically -
android - how to control ImageView Gravity Dynamically -
i have listview this:
 <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" >    <linearlayout     android:id="@+id/wrapper"     android:layout_width="fill_parent"     android:layout_height="wrap_content" >    <imageview     android:id="@+id/msgimage"     android:layout_width="50dp"     android:layout_height="50dp"     android:src="@drawable/abc_ab_bottom_solid_dark_holo" />      <textview         android:id="@+id/msgname"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="textview" />      <textview         android:id="@+id/comment"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_margin="5dip"         android:background="@drawable/bubble_yellow"         android:paddingleft="10dip"         android:text="hello bubbles!"         android:textcolor="@android:color/primary_text_light" />  </linearlayout>  </linearlayout>    and command kid linearlayout this:
wrapper = (linearlayout) row.findviewbyid(r.id.wrapper);       themessage = (textview) row.findviewbyid(r.id.comment);     thename = (textview) row.findviewbyid(r.id.msgname);     theimage = (imageview)row.findviewbyid(r.id.msgimage);       string namer=   mcursor.getstring(mcursor.getcolumnindex(mydbhelpersinglechat.col_username));            string namer[] = namer.split("\\@");            string imagenamer=namer[0];      thename.settext(imagenamer);  themessage.settext(mcursor.getstring(mcursor.getcolumnindex (mydbhelpersinglechat.col_messag  e)));      int isright=   integer.valueof(mcursor.getstring(mcursor.getcolumnindex("isright")));      themessage.setbackgroundresource(isright==0 ? r.drawable.bubble_yellow :   r.drawable.bubble_green);     wrapper.setgravity(isright==0 ? gravity.left : gravity.right);     thename.setgravity(isright==0 ? gravity.left : gravity.right);       file file= new file("storage/sdcard/lifemateprivate/profileimage  /profileimage,imagechange_2,"+imagenamer+",.jpg");     if(file.exists()){     picasso.with(mcontext).load(new file("storage/sdcard/lifemateprivate   /profileimage /profileimage,imagechange_2,"+imagenamer+",.jpg")).resize(100,100 ).centercrop().into(theima    ge);     }else{     picasso.with(mcontext).load(new file("storage/sdcard/lifemateprivate   /profileimage/default.jpg")).resize(100,100).centercrop().into(theimage);     }    the problem is, imageview default @ left side of view, want when gravity right, moves right side of textview's .could please help me accomplish that? alot.
 android android-linearlayout 
 
Comments
Post a Comment