Cara menganti background edit text di pemerograman androi (Eclipse Android stuio)
Pertama silakan buat projek baru agan baik yang mengunakan android studio ataupun eclipse
1. Code for MainActivity.java file.
2.Code for activity_main.xml layout file.
Pertama silakan buat projek baru agan baik yang mengunakan android studio ataupun eclipse
1. Code for MainActivity.java file.
package com.basithsteviejhei.blogspot.com
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
2.Code for activity_main.xml layout file.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.edittextlikeiphone_android_examples.com.MainActivity" >
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="55dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:ems="10"
android:gravity="center"
android:background="@layout/iphone_edittext_into_android"
android:hint="Iphone Like EditText" >
<requestFocus />
</EditText>
</RelativeLayout>
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.edittextlikeiphone_android_examples.com.MainActivity" >
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="55dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:ems="10"
android:gravity="center"
android:background="@layout/iphone_edittext_into_android"
android:hint="Iphone Like EditText" >
<requestFocus />
</EditText>
</RelativeLayout>
3.membuat file baru di folder drawble dengan nama "iphone_edittext_into_android.xml file."
iphone_edittext_into_android.xml file.
<?xml version="1.0" encoding="utf-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:color="#028b53"
android:width="2.5dp" />
<corners android:radius="10dp" />
<gradient
android:type="linear"
android:angle="270"
android:startColor="#c3c3c3"
android:endColor="#FFFFFF" />
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:color="#028b53"
android:width="2.5dp" />
<corners android:radius="10dp" />
<gradient
android:type="linear"
android:angle="270"
android:startColor="#c3c3c3"
android:endColor="#FFFFFF" />
</shape>
Hasil gambar.
Post a Comment
Post a Comment