首页 > 解决方案 > 两个视图之间从左,右和中心的相等空间android

问题描述

嘿伙计们请帮帮我。我希望两个文本视图之间的左、右和中心空间相等。下面是我想要的视图图像。在此处输入图像描述

两个文本视图宽度都可以根据文本在运行时增加和减少。

标签: androidandroid-studiotextviewspace

解决方案


用这个

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

<View
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"/>

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

<View
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"/>

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>


</LinearLayout>

推荐阅读