Android 风格不适用
我使用以下代码创建了样式:Android 风格不适用,android,android-layout,Android,Android Layout,我使用以下代码创建了样式: <?xml version="1.0" encoding="utf-8"?> <resources> <style name="CodeFont" parent="@android:style/TextAppearance.Medium"> <item name="android:layout_width">150dip</item> <ite
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CodeFont" parent="@android:style/TextAppearance.Medium">
<item name="android:layout_width">150dip</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#00FF00</item>
<item name="android:typeface">monospace</item>
</style>
</resources>
150度
包装内容
#00FF00
单空间
并将其应用为:
<EditText
style="CodeFont"
android:id="@+id/txt_username"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
但它没有得到应用
如果我使用与以下相同的样式书写:
<EditText
android:id="@+id/txt_username"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:ems="10"
android:inputType="textPersonName" />
然后应用它
我的代码有什么问题吗
请帮助我。使用下面的
style="@style/CodeFont"
有关更多信息,请查看文档
还可以检查styles.xml
改变
style="CodeFont"
style="CodeFont"
到
你应该改变
到
你应该使用
style="@style/your_style_xml"
这是在android xml中应用样式的正确方法,只需更改此项即可
style="CodeFont"
对此
style=@style/CodeFont
希望这对您有所帮助..**themes.xml**
**themes.xml**
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ijoomer_theme" parent="define your parent theme here">
<item name="edittext">@style/CodeFont</item>
</style>
</resources>
**attrs.xml**
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="edittext" format="reference" />
</resources>
**style.xml**
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CodeFont" parent="@android:style/TextAppearance.Medium">
<item name="android:layout_width">150dip</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#00FF00</item>
<item name="android:typeface">monospace</item>
</style>
</resources>
**use edittext style**
<EditText
style="?CodeFont" // this way you use your custom style
android:id="@+id/txt_username"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
@样式/代码字体
**attrs.xml**
**style.xml**
150度
包装内容
#00FF00
单空间
**使用编辑文本样式**
请更改
style="CodeFont"
到
这是正确的方法@navatkayahe欢迎您检查文档是否有关于该主题的更多详细信息实际上我参考了,但犯了错误。。。抱歉,第一次造型…android新增
**themes.xml**
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ijoomer_theme" parent="define your parent theme here">
<item name="edittext">@style/CodeFont</item>
</style>
</resources>
**attrs.xml**
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="edittext" format="reference" />
</resources>
**style.xml**
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CodeFont" parent="@android:style/TextAppearance.Medium">
<item name="android:layout_width">150dip</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#00FF00</item>
<item name="android:typeface">monospace</item>
</style>
</resources>
**use edittext style**
<EditText
style="?CodeFont" // this way you use your custom style
android:id="@+id/txt_username"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
style="CodeFont"
style="@style/CodeFont"