【发布时间】:2015-07-02 10:52:22
【问题描述】:
我在LinearLayout 中有一个ImageButton。我尝试将ImageButton 放在水平LinearLayout 的右侧。我使用layout_gravity="right",但它不起作用。请帮帮我。
<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>
【问题讨论】:
-
是否需要布局嵌套?为什么不用
RelativeLayout?