android– 如何在水平LinearLayout中将ImageButton对齐到右边

android– 如何在水平LinearLayout中将ImageButton对齐到右边,第1张

概述我在LinearLayout中有一个ImageButton.我尝试将ImageButton放在水平LinearLayout的右侧.我使用layout_gravity=“right”但它不起作用.请帮我.<LinearLayoutxmlns:android="http://schemas.android.com/apkes/android"xmlns:tools="http://schemas.android.comoo

我在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 – 如何在水平LinearLayout中将ImageButton对齐右边全部内容,希望文章能够帮你解决android – 如何在水平LinearLayout中将ImageButton对齐到右边所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1119192.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存