如何在android中设置编辑文本框的样式
我试图添加一个风格的编辑文本,但它不工作,我试图给它一个高度,它没有改变,代码如下如何在android中设置编辑文本框的样式,android,xml,Android,Xml,我试图添加一个风格的编辑文本,但它不工作,我试图给它一个高度,它没有改变,代码如下 <style name="rounded_text" parent="@android:style/Widget.EditText"> <item name="android:background">@drawable/rounded_edittext</item> <item name="android:layout_height">30dp<
<style name="rounded_text" parent="@android:style/Widget.EditText">
<item name="android:background">@drawable/rounded_edittext</item>
<item name="android:layout_height">30dp</item>
<item name="android:paddingLeft">5dp</item>
<item name="android:paddingRight">5dp</item>
</style>
@可绘制/四舍五入文本
30dp
5dp
5dp
在文本中,它看起来像这样
<?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">
<solid
android:color="#ffffff"></solid>
<corners
android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp"/>
</shape>
我试图更改文本字段内的高度和填充,只是试图防止代码重复:)
我也尝试过这样做以防万一,但由于明显的原因,它没有起作用:p
<style name="rounded_text" parent="@android:style/Widget.EditText">
<item name="android:shape">rectangle</item>
<item name="android:layout_height">50dp</item>
<item name="android:paddingLeft">5dp</item>
<item name="android:paddingRight">5dp</item>
<item name="android:color">#FFFFFF</item>
<item name="android:bottomRightRadius">10dp</item>
<item name="android:bottomLeftRadius">10dp</item>
<item name="android:topRightRadius">10dp</item>
<item name="android:topLeftRadius">10dp</item>
</style>
矩形
50dp
5dp
5dp
#FFFFFF
10dp
10dp
10dp
10dp
如果尚未执行此操作,可以尝试从XML布局文件中的EditText
视图调用样式,如下所示:
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/rounded_text" />
我使用了它,我一直很愚蠢,我基本上是自相矛盾的,我在样式和布局xml中都有布局高度,所以确保在向样式中添加某些内容时。。。将其从正在使用的INSERT_LAYOUT_NAME.XML中删除 我忘了说我已经这么做了:/谢谢你的回答!:)是因为没有设置高度和填充物,还是因为包括圆角在内的所有东西?设法回答了我自己的问题,我只是在两个不同的地方设置了布局高度来反驳自己,傻我!