使用网格布局将不同长度的垂直文本视图对齐到相同的右边缘

Align vertical text views of different lengths to same right edge using Grid Layout

我想使用网格布局制作此图像的细节部分,但我面临的问题是,当它们具有不同的 lengths.My 文本视图起点时,我的文本视图并没有在彼此下方结束相同的终点是不同的,但在这个图像布局中,它们在彼此下方结束。 例如,Vol 的值比 low 的值有更多的位数,但两者都有相同的终点。 我如何使用网格布局实现此目的? 这是我的代码

<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="4"
android:rowCount="4"
android:padding="8dp"
android:orientation="horizontal"
android:background="@drawable/toolbar_background">

<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#fff"
    android:text="Open"/>

<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#fff"
    android:layout_marginLeft="30dp"
    android:text="36.40"/>

<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#fff"
    android:layout_marginLeft="10dp"
    android:text="MktCap"/>

<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#fff"
    android:layout_marginLeft="30dp"
    android:text="33.39B"/>

<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#fff"
    android:layout_marginTop="10dp"
    android:text="High"/>

<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#fff"
    android:layout_marginLeft="30dp"
    android:layout_marginTop="10dp"
    android:text="36.95"/>

<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#fff"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="10dp"
    android:text="52WkHigh"/>

<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#fff"
    android:layout_marginLeft="30dp"
    android:layout_marginTop="10dp"
    android:text="42.31"/>

<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#fff"
    android:layout_marginTop="10dp"
    android:text="Low"/>

<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#fff"
    android:layout_marginLeft="30dp"
    android:layout_marginTop="10dp"
    android:text="36.08"/>

<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#fff"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="10dp"
    android:text="52WkLow"/>

<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#fff"
    android:layout_marginLeft="30dp"
    android:layout_marginTop="10dp"
    android:text="26.15"/>

<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#fff"
    android:layout_marginTop="10dp"
    android:text="Vol"/>

<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#fff"
    android:layout_marginLeft="30dp"
    android:layout_marginTop="10dp"
    android:text="19.66M"/>

<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#fff"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="10dp"
    android:text="P/E"/>

<TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#fff"
    android:layout_marginLeft="30dp"
    android:layout_marginTop="10dp"
    android:text="1.25"/>

使用

android:layout_gravity="right"

在所有您想要在彼此下方结束的 textview 中。 你也可以添加这个

 android:gravity="right"