Android layout issue when centering image -
i'm trying code layout of item in list. idea want picture shown @ right of item, centered horizontally , vertically. i'm embedding image in container, put padding in order image not touch boundaries. i'm inflating image imageview calling setimagebitmap() in java code. problem images not shown want, not centered , other times touch boundaries of item (even if set padding!). tell me if i'm doing wrong please?
here xml:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" > <relativelayout android:id="@+id/content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" > <textview android:id="@+id/thing1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="2dp" android:text="blablablabla" android:textsize="16sp" /> <textview android:id="@+id/thing2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/thing1" android:layout_marginbottom="2dp" android:text="7(2)" android:textcolor="@color/green" android:textsize="14sp" /> <textview android:id="@+id/thing3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/thing2" android:layout_marginbottom="3dp" android:text="mytext" android:textsize="12sp" /> </relativelayout> <relativelayout android:id="@+id/photocontainer" android:layout_width="100dp" android:layout_height="fill_parent" android:layout_alignbottom="@+id/content" android:layout_alignparentright="true" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" > <imageview android:id="@+id/photo" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerhorizontal="true" android:layout_centervertical="true" /> </relativelayout> </relativelayout>
in relativelayout
android:id="@+id/photocontainer"
change height android:layout_height="100dp"
. since it's fill_parent of area occupied on each row depend of height of image. add android:scaletype="fitxy"
in imageview
.
hope solves issue.
Comments
Post a Comment