Android 使TextView自动适应视图的中间位置

Android 使TextView自动适应视图的中间位置,android,android-layout,user-interface,android-linearlayout,android-layout-weight,Android,Android Layout,User Interface,Android Linearlayout,Android Layout Weight,我正在制作我的应用程序,但我无法实现此目标,我需要获得以下信息: 问题是我需要的部分 6:1.33 /强>左边,加扰(中间所有字母)和右边的按钮。 我尝试了一些方法,比如使用体重,但我仍然无法做到这一点。我也尝试过relativeLayout,但仍然没有。我让您知道我所做的代码: <android.support.v7.widget.CardView app:cardBackgroundColor="?attr/cardBackgroundColor" android:l

我正在制作我的应用程序,但我无法实现此目标,我需要获得以下信息:

问题是我需要的部分<强> 6:1.33 /强>左边,加扰(中间所有字母)和右边的按钮。 我尝试了一些方法,比如使用体重,但我仍然无法做到这一点。我也尝试过relativeLayout,但仍然没有。我让您知道我所做的代码:

<android.support.v7.widget.CardView
    app:cardBackgroundColor="?attr/cardBackgroundColor"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
   <LinearLayout
       android:weightSum="3"
       android:layout_width="match_parent"
       android:orientation="horizontal"
       android:layout_height="wrap_content">
       <TextView
           android:layout_weight="1"
           android:padding="10dp"
           android:layout_width="wrap_content"
           android:textColor="?attr/primaryTextColor"
           android:text="105: 46.23"
           android:layout_height="wrap_content" />
       <TextView
           android:layout_weight="1.5"
           android:padding="10dp"
           android:layout_width="wrap_content"
           android:textColor="?attr/secondaryTextColor"
           android:text="F2 R B L2 F R B L2 F R B2 L' R2 B F"
           android:layout_height="wrap_content" />
       <LinearLayout
           android:layout_weight="0.5"
           android:orientation="horizontal"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content">

           <Button
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:background="@color/fui_transparent"
               android:text="+2"/>
           <Button
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:background="@color/fui_transparent"
               android:text="DNF"/>
       </LinearLayout>
   </LinearLayout>
</android.support.v7.widget.CardView>

删除

android:weightSum="3"
诸如此类

android:layout_weight="xx"

android:layout_weight="1"
到您的扰码文本视图应该做到这一点。您的第一个文本视图应该位于左侧,按钮位于右侧。剩余的空间将从您的扰码文本视图中获取。

使用RelativeLayout

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
            <TextView
                android:padding="10dp"
                android:layout_alignParentLeft="true"
                android:id="@+id/leftView"
                android:layout_width="wrap_content"
                android:text="105: 46.23"
                android:layout_height="wrap_content" />
            <TextView
                android:id="@+id/midddleView"
                android:layout_toRightOf="@id/leftView"
                android:layout_toLeftOf="@id/rightView"
                android:padding="10dp"
                android:layout_width="match_parent"
                android:text="F2 R B L2 F R B L2 F R B2 L' R2 B F"
                android:layout_height="wrap_content" />
            <LinearLayout
                android:id="@+id/rightView"
                android:layout_alignParentRight="true"
                android:orientation="horizontal"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="+2"/>
                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="DNF"/>
            </LinearLayout>
</RelativeLayout>