5 EYLÜL 2010, Pazar
Nasıl yuvarlak köşeler ile EditText oluşturma?
Yuvarlak hatlara sahip EditText
oluşturmak için herhangi bir yolu var mı?
CEVAP
5 EYLÜL 2010, Pazar
Bir CommonsWare tarafından yazılmış daha kolay bir yolu var. Sadece yol belirten drawable bir kaynak oluşturmak EditText
çekilecek:
<?xml version="1.0" encoding="utf-8"?>
<!-- res/drawable/rounded_edittext.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#FFFFFF"/>
<corners
android:bottomRightRadius="15dp"
android:bottomLeftRadius="15dp"
android:topLeftRadius="15dp"
android:topRightRadius="15dp"/>
</shape>
O zaman, sadece referans düzeni bu drawable:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dip"
android:background="@drawable/rounded_edittext" />
</LinearLayout>
Gibi bir şey olacaktır:
Edit
Mark yoruma dayanan, EditText
için: farklı devletler oluşturabilirsiniz bu şekilde eklemek istiyorum
<?xml version="1.0" encoding="utf-8"?>
<!-- res/drawable/rounded_edittext_states.xml -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/rounded_focused" />
<item
android:state_focused="true"
android:state_enabled="true"
android:drawable="@drawable/rounded_focused" />
<item
android:state_enabled="true"
android:drawable="@drawable/rounded_edittext" />
</selector>
Bu devletler şunlardır:
<?xml version="1.0" encoding="utf-8"?>
<!-- res/drawable/rounded_edittext_focused.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#FFFFFF"/>
<stroke android:width="2dp" android:color="#FF0000" />
<corners
android:bottomRightRadius="15dp"
android:bottomLeftRadius="15dp"
android:topLeftRadius="15dp"
android:topRightRadius="15dp"/>
</shape>
Ve... şimdi, EditText
gibi görünmelidir:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:background="@drawable/rounded_edittext_states"
android:padding="5dip"/>
</LinearLayout>
Bunu Paylaş:
CSS3'border-radius özelliği ve sı...
Nasıl(x) sonunda düğmeye Haç ile EditT...
Explorer gibi yuvarlak köşeler ile seç...
Nasıl dosya oluşturma ve Tarih değişik...
# - c Nasıl 2 ondalık basamak (bir say...