Android – how to align the imagebutton to the right in the horizontal LinearLayout
•
Android
I have an imagebutton in the LinearLayout. I try to put the imagebutton to the right of the horizontal LinearLayout. I use layout_ Gravity = "right" but it doesn't work. Please help me
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="5"
tools:context="com.startsoft.musicalsound.MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
android:background="@drawable/img_bg_header"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/btn_menu"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="right"
android:background="@android:color/transparent"
android:src="@drawable/ic_action_sort_by_size" />
</LinearLayout>
resolvent:
Use Android: gravity = "right" on the parent layout of imagebutton. You can also delete Android: layout from it_ gravity =“right”.
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码