android:orientation = horizontal的 线性布局 。
Use a horizontal LinearLayout
in your layout along with 3 TextInputLayout
Views each having an EditText
. Something like:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="@+id/layout1"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:hint="MM">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="number"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/layout2"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:hint="YY">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="number"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/layout3"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:hint="CVV">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="number"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
If you could provide more Details, eg which Layout you use you'll get better answers
For a LinearLayout i would guess something like
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText3"
android:layout_weight="1"
android:layout_marginTop="50dp"
android:text="xxx"
android:gravity="center" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText4"
android:layout_weight="1"
android:layout_marginTop="50dp"
android:gravity="center"
android:text="yyy" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText5"
android:layout_weight="1"
android:layout_marginTop="50dp"
android:text="zzz"
android:gravity="center" />
would match your question
Step 1: Create Drawable named demo.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke android:color="#000000" android:width="5dp"/>
</shape>
step 2:Create layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/demo"
android:layout_margin="10dp"
android:orientation="horizontal"
android:gravity="center"
android:weightSum="3">
<EditText
android:layout_width="100dp"
android:layout_height="wrap_content"
android:hint="MM"
android:layout_weight="1"
android:gravity="center"/>
<EditText
android:layout_width="100dp"
android:layout_height="wrap_content"
android:hint="YY"
android:layout_weight="1"
android:gravity="center"/>
<EditText
android:layout_width="100dp"
android:layout_height="wrap_content"
android:hint="CVV"
android:layout_weight="1"
android:gravity="center"/>
</LinearLayout>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.