我想在一个TextInputLayout中添加两个TextInputEditText,如下所示:
我试图这样做:
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:layout_weight="0.8"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/material_margin">
<android.support.design.widget.TextInputEditText
android:id="@+id/profile_height_edit_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:hint="@string/growth"
android:inputType="number"
android:maxLength="3"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_weight="0.2"
android:layout_width="0dp"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
但是我有两个TextInputEditText
之间的空格(标有红线)
也许有人知道更好的解决方案(两个TextInputEditTexts之间没有任何空格)
谢谢!
答案 0 :(得分:3)
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/MB_reading_layout_wrapper">
<android.support.design.widget.TextInputLayout
android:id="@+id/MB_reading_layout_wrapper_1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/MB_reading_text_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:hint="Weight"
android:inputType="numberDecimal"
android:textSize="20sp" />
</android.support.design.widget.TextInputLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:textAlignment="center"
android:gravity="center"
android:textSize="20sp"
android:text="kg" />
</RelativeLayout>
Instead of using a TextView, you may use an EditText.