Android : Align image on top right hand corner of button -
i have image looks checkbox, align on top right hand corner of button. have tried relative layout not achieve desired result. suggestion achieve desired result?
i have tried using framelayout checbox image remains hidden
<framelayout android:layout_marginleft="10dp" android:layout_margintop="20dp" android:layout_width="wrap_content" android:layout_height="wrap_content"> <imageview android:id="@+id/filter_check" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/checkmark" android:layout_gravity="right" /> <button android:id="@+id/filter" style="@style/widget.button.white.bluetext.bluestroke" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="filter" /> </framelayout>
after farouk's suggestions use button before image. here code
<framelayout android:layout_marginleft="10dp" android:layout_margintop="20dp" android:layout_width="wrap_content" android:layout_height="wrap_content"> <button android:id="@+id/filter" style="@style/widget.button.white.bluetext.bluestroke" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="filter" /> <imageview android:id="@+id/filter_check" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/checkmark" android:layout_gravity="top|right" /> </framelayout>
here see on designer.
not sure how move checkbox image , right.
in case want solution, here is:
<framelayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="10dp" android:layout_margintop="80dp" > <button android:id="@+id/filter" style="@style/widget.button.white.bluetext.bluetext.frameimage" android:layout_margin="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="sort" /> <imageview android:id="@+id/widget_title_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top|right" android:src="@drawable/checkmark" /> </framelayout> <style name="widget.button.white.bluetext.bluetext.frameimage" parent="@android:style/widget.button"> <item name="android:background">@drawable/white_button_blue_stroke_bg_selector</item> <item name="android:gravity">center</item> <item name="android:textcolor">@color/white</item> <item name="android:textappearance">?android:attr/textappearancemedium</item> </style>
solution:
it :
just play android:paddingtop="-10dp" like.
here code :
<button android:id="@+id/filter" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="7dp" android:background="#0000ff" android:gravity="center" android:paddingbottom="25dp" android:paddingtop="25dp" android:text="sort" android:textcolor="#ffffff" /> <imageview android:id="@+id/widget_title_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top|right" android:adjustviewbounds="true" android:paddingtop="-10dp" android:scaletype="fitstart" android:src="@drawable/checkbtn" /> </framelayout>
Comments
Post a Comment