I found a semi-solution for this online.
First, you need to add the dependency for the Android design library in your main build.gradle file:
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.android.support:design:22.2.0' }
Then you can use the projects provided by the library in your XML using:
<android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/PhoneNumberTILayout" android:layout_marginTop="@strings/my_margin_top"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Phone Number" /> </android.support.design.widget.TextInputLayout>
Now I canβt find a way to get 2 children TextInputLayout ... It's just not how it should work ... But you can just add another one that will work just as well. In your case, all you have to do is make your main Relative layout and then set the TILayout position of the country code relative to the TILayout phone number.
This is what I have for the relativelayout part:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.android.testapp.MainActivity" > <android.support.design.widget.TextInputLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:id="@+id/TILayout" android:layout_alignParentTop="true" android:layout_alignParentStart="true" android:layout_marginStart="11dp" android:layout_marginTop="20dp"> <EditText android:layout_width="wrap_content" android:layout_height="match_parent" android:hint="Code" android:textSize="26sp" android:ems="3" android:id="@+id/PhoneCode" /> <android.support.design.widget.TextInputLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/PhoneNumberTILayout" android:layout_marginTop="-64dp" android:layout_marginLeft="100dp"> <EditText android:layout_width="wrap_content" android:layout_height="match_parent" android:hint="Phone Number" android:textSize="26sp" android:ems="6" android:id="@+id/PhoneNumber" /> </android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout> </RelativeLayout>
I hope I helped: D
Rippr source share