如何更改默认 EditText 的样式 [英] How to change style of a default EditText

查看:63
本文介绍了如何更改默认 EditText 的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这样的代码在我的 xml 文件中创建三个 EditText:

I am creating three EditTexts 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.

推荐答案

你有几个选择.

  1. 使用 Android 资产工作室 Android Holo 颜色生成器 生成您需要添加到应用中的资源、样式和主题以获得所有设备的全息外观.

  1. 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 的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆