LinearLayout对齐问题

LinearLayout对齐问题

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <!--头部-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="发现"
            android:textSize="24sp"
            android:textStyle="bold" 
            android:layout_gravity="center"/>

        <ImageView
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:src="@mipmap/find_news"
            android:layout_gravity="right"/>

    </LinearLayout>

</RelativeLayout>

http://img1.sycdn.imooc.com//climg/5b92439100018d0202840475.jpg

我想让中间的字居中,右边的图标右对齐做不到么,(水平方式下只能上下对齐么),一定要再嵌套一个LinearLayout么

正在回答

登陆购买课程后可参与讨论,去登陆

1回答

不一定呀,很多种方式呢。例如你在发现左侧增加一个占位的控件,只是不让它显示出来。或者你用相对布局,让发现放在中间位置。这都是可以的。

  • WillyTsui 提问者 #1
    水平方式下只能上下对齐么
    2018-09-07 18:47:28
  • 好帮手慕雪 回复 提问者 WillyTsui #2
    LinearLayout中?是的
    2018-09-07 18:50:25
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师