android - Aligning an image to the right of RelativeLayout without streatching -
i have relative layout has background image. set height , width wrap_content. works fine. want place image @ topright corner of relative layout. use alignparentright = true. problem relative layout stretches horizontally fill screen.
i have done reading , came across "circular dependency pitfall"
from relativelayout doc:
class overview
a layout positions of children can described in relation each other or parent.
note cannot have circular dependency between size of relativelayout , position of children. example, cannot have relativelayout height set wrap_content , child set align_parent_bottom
here xml sample
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="@drawable/popup_b" android:layout_width="wrap_content" android:layout_height="wrap_content" > <imagebutton android:id="@+id/ibclosedialog" android:background="@null" android:layout_width="wrap_content" android:layout_height="wrap_content" android:alignparentright="true" android:src="@drawable/close" /> </relativelayout>
and that's facing. there recommendation or way achieve want? want the relativelayout big background image , image @ top right corner of that.
thank much
have tried setting gravity right
?
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="@drawable/popup_b" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" > <imagebutton android:id="@+id/ibclosedialog" android:background="@null" android:layout_width="wrap_content" android:layout_height="wrap_content" android:alignparentright="true" android:src="@drawable/close" /> </relativelayout>
Comments
Post a Comment