問題描述
如果我使用下面的代碼更改我的 EditText
的背景顏色,看起來該框已縮小,并且它不保持默認存在的藍色底邊框的 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>
這是它的樣子:
推薦答案
你應該做的是為edittext創建一個9補丁圖像并將該圖像設置為編輯文本背景.您可以使用 this 網站
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
我附上一個示例 9 補丁圖像供您參考.將其用作編輯文本背景,您會得到一個想法.右鍵單擊圖像并選擇圖像另存為".保存圖片時不要忘記將其擴展名設為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"
這篇關于在android中更改edittext的背景顏色的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!