問(wèn)題描述
如果我使用下面的代碼更改我的 EditText
的背景顏色,看起來(lái)該框已縮小,并且它不保持默認(rèn)存在的藍(lán)色底邊框的 ICS 主題EditText
.
If I change the background color of my EditText
using the below code, it looks like the box is shrunken and it doesn't maintain the ICS theme of a blue bottom border that exists for a default EditText
.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#99000000"
>
<EditText
android:id="@+id/id_nick_name"
android:layout_marginTop="80dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:orientation="horizontal"
android:layout_below="@+id/id_nick_name">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="add"
android:layout_weight="1"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="cancel"
android:layout_weight="1"
/>
</LinearLayout>
</RelativeLayout>
這是它的樣子:
推薦答案
你應(yīng)該做的是為edittext創(chuàng)建一個(gè)9補(bǔ)丁圖像并將該圖像設(shè)置為編輯文本背景.您可以使用 this 網(wǎng)站
What you should do is to create a 9 patch image for edittext and set that image as edit text background. You can create 9 patches using this website
我附上一個(gè)示例 9 補(bǔ)丁圖像供您參考.將其用作編輯文本背景,您會(huì)得到一個(gè)想法.右鍵單擊圖像并選擇圖像另存為".保存圖片時(shí)不要忘記將其擴(kuò)展名設(shè)為9.png"
I am attaching a sample 9 patch image for your reference.Use it as edittext background and you will get an idea.Right click the image and select "save image as". When you save the image dont forget to give its extension as "9.png"
這篇關(guān)于在android中更改edittext的背景顏色的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!