首页 > 解决方案 > 如何证明 Android Studio 中的内容 - XML

问题描述

我想知道是否有可能LinearLayout像我通常为 web 所做的那样证明 Android Studio 中的内容是合理的。

网页 CSS

.space-around {
  display: flex;
  justify-content: space-around;
}

什么space-around是在行中均匀分布,周围有相等的空间,使内容适合 div (链接

我怎样才能在我的 Android Studio 中获得相同的效果LinearLayout

安卓

  <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="90dp"
            android:orientation="horizontal">
  </LinearLayout>

标签: androidxmljustify

解决方案


你可以这样:只要给 LinearLayout 的内部元素同样的权重:

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    >
    <TextView
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        />
    <TextView
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        />
    <TextView
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
    />
    <TextView
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
    />
</LinearLayout>

推荐阅读