Mostly
iphone only use this type of grouped edittext.here i explain how to
do that same in android i hope this will be very useful for
everyone.
Using this code
Step1:
1.use round.xml for round cornered grouped edittext.and this xml file placed under drawable folders only
round.xml:
round.xml:
<?xml
version="1.0"
encoding="UTF-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
>
<solid
android:color="#E6E6E6"
/>
<stroke
android:width="1.5dp"
android:color="#0489B1"
/>
<padding
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp"
/>
<corners
android:bottomLeftRadius="20dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp"
/>
</shape>
Step2:
1.Create relative layout and set round.xml as background and also set height.
2.Then plan edittext inside relative layout also remove background of edittext,use this code to
remove or hide backgound
android:background="@null"
3.Create one view its for horizontal line.
<View
android:id="@+id/view1"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="@+id/editText1"
android:background="#c0c0c0"
/>
4.android:imeOptions="actionNext" use this for keyboard next options occur during first and second edittext filling time.and android:imeOptions="actionDone" its used for colse the soft keyboard
activity_main.xml:
MainActivity.java:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#A4A4A4" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="124dp"
android:layout_centerInParent="true"
android:layout_margin="20dp"
android:layout_marginTop="30dp"
android:background="@drawable/round" >
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="@null"
android:ems="10"
android:hint="Name"
android:hint="Name"
android:imeOptions="actionNext"
android:padding="10dp"
android:singleLine="true" >
<requestFocus />
</EditText>
<View
android:id="@+id/view1"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="@+id/editText1"
android:background="#c0c0c0" />
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="@+id/view1"
android:background="@null"
android:ems="10"
android:hint="Age"
android:imeOptions="actionNext"
android:padding="10dp"
android:singleLine="true" >
</EditText>
<View
android:id="@+id/view2"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="@+id/editText2"
android:background="#c0c0c0" />
<EditText
android:id="@+id/editText3"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignRight="@+id/view2"
android:layout_below="@+id/view2"
android:background="@null"
android:ems="10"
android:hint="Country"
android:imeOptions="actionDone"
android:padding="10dp"
android:singleLine="true" >
</EditText>
</RelativeLayout>
</RelativeLayout>
MainActivity.java:
package
com.example.round;
import
android.app.Activity;
import
android.os.Bundle;
import
android.view.Window;
import
android.view.WindowManager;
public
class
MainActivity extends
Activity {
@Override
protected
void
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Used
for edittext
scroll smoothly for keyboard entry
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
//hide
android default header
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
}
}
Happy coding...
1 comments:
Write commentsI'm гeally enjoying the desdign andd layout off your blog.
ReplyIt's a very easy on the eyes wһich mzkes іt mᥙch moгe pleasant fоr me too come here aand visit mоre ᧐ften. Ꭰid уou hire out a designer tо create yiur theme?
Fantastic wοrk!
EmoticonEmoticon