問題描述
我正在使用這樣的代碼在我的 xml 文件中創建三個 EditText
:
I am creating three EditText
s in my xml file using code like this:
<EditText
android:id="@+id/name_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/profile_image_view_layout"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:ems="15"
android:hint="@string/name_field"
android:inputType="text" />
當我運行應用程序時,它在我的設備上看起來像這樣:
When I run the app, it looks like this on my device:
但我希望它看起來像這樣,不使用任何背景圖片:
But I want it to look like this, without using any background image:
那怎么做呢?任何想法或建議都會有所幫助.
So how can that be done? Any ideas or suggestions will be helpful.
推薦答案
你有幾個選擇.
使用 Android 資產工作室 Android Holo 顏色生成器 生成您需要添加到應用中的資源、樣式和主題以獲得所有設備的全息外觀.
Use Android assets studios Android Holo colors generator to generate the resources, styles and themes you need to add to your app to get the holo look across all devices.
使用 holo 無處不在 庫.
對全息文本字段使用 PNG,并自己將它們設置為背景圖像.您可以從 Android assets studios holo color generator 獲取圖像.您必須創建一個可繪制對象并定義正常、選定和禁用狀態.
Use the PNG for the holo text fields and set them as background images yourself. You can get the images from the Android assets studios holo color generator. You'll have to make a drawable and define the normal, selected and disabled states.
2016 年 1 月 7 日更新
這個答案現在已經過時了.Android 現在具有著色 API 和直接在控件上設置主題的能力.一個名為 materialdoc 的網站是關于如何為任何元素設置樣式或主題的一個很好的參考.
This answer is now outdated. Android has tinting API and ability to theme on controls directly now. A good reference for how to style or theme any element is a site called materialdoc.
這篇關于如何更改默認 EditText 的樣式的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!