0
点赞
收藏
分享

微信扫一扫

ArcgisForJS如何访问Arcgis Server?

RockYoungTalk 2024-02-25 阅读 12
android

Android LinearLayout 如何让子元素靠下居中对齐 center bottom

首先你需要知道两个知识点:

  • android:layout_gravity 指定的是当前元素在父元素中的位置
  • android:gravity 指定的是当前元素子元素的排布位置

比如:

有这么一个布局,我需要让它靠下居中对齐,LinearLayout 上的 gravity = center 是对的,指定的是它的子元素应该居中排布。

在这里插入图片描述

<LinearLayout
    android:gravity="center"
    android:orientation="horizontal"
    android:layout_marginBottom="20dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <ImageView
        android:layout_marginEnd="10dp"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:src="@mipmap/ic_launcher">
    </ImageView>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/white"
        android:text="蓝牙权限状态"
        android:textSize="24dp"
        android:textFontWeight="600"
        />
    <TextView
        android:layout_marginLeft="10dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/gary"
        android:text="@string/version"
        android:textSize="16dp"
        />
</LinearLayout>

那么如何让子元素靠下排列呢?那就是子元素该定义的了,所以我们在每个子元素中再添加 layout_gravity = bottom 即可。

在这里插入图片描述

举报

相关推荐

0 条评论