簡體   English   中英

如何在水平LinearLayout中將ImageButton對齊到右側

[英]How to align ImageButton to right in horizontal LinearLayout

我在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>

ImageButton的父布局上使用android:gravity="right" 你也可以從中刪除android:layout_gravity="right"

像這樣將按鈕的重力設置為右:android:layout_gravity =“right”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM