【问题标题】:ICS style EditText for API level 8API 级别 8 的 ICS 样式 EditText
【发布时间】:2013-04-18 22:46:47
【问题描述】:

如何为 ICS 中带有 Holo 主题的 EditText 设置样式,以使其与 API 级别 8 的设备兼容。

我尝试了以下代码,但它与 API 8 不兼容。

<EditText
        android:id="@+id/editText1"
        style="@android:style/Widget.Holo.EditText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>

【问题讨论】:

    标签: android android-edittext android-holo-everywhere


    【解决方案1】:

    你可以使用HoloEveryWhere

    或者你可以这样做:

    <style name="MyTheme" parent="@android:style/Theme">
        <item name="android:editTextBackground">@drawable/my_edittext</item>
    </style>
    

    my_edittext.xml:

    <?xml version="1.0" encoding="utf-8"?>
    
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/textfield_default_holo_light" />
        <item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/textfield_disabled_holo_light" />
        <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_activated_holo_light" />
        <item android:state_enabled="true" android:state_activated="true" android:drawable="@drawable/textfield_focused_holo_light" />
        <item android:state_enabled="true" android:drawable="@drawable/textfield_default_holo_light" />
        <item android:state_focused="true" android:drawable="@drawable/textfield_disabled_focused_holo_light" />
        <item android:drawable="@drawable/textfield_disabled_holo_light" />
    </selector>
    

    您可以在 SDK 文件夹中找到上述可绘制对象。

    【讨论】:

    • 嗨,它没有获取可绘制资源。
    • 我明白了。我想我需要从您共享的 HoloEveryWhere 链接中获取资源。酷...我会试试看。
    • 像冠军一样工作...谢谢... :)
    • @Ahmad 你是冠军!!并感谢 Manjunath 提出这个问题..:)
    【解决方案2】:

    由您自己创建类似的设计。您可以使用 api 16 的资源。您可以在 /android-sdks/platforms/android-16/data/res/ 文件夹中找到这些资源

    【讨论】:

      猜你喜欢
      • 2012-04-28
      • 1970-01-01
      • 1970-01-01
      • 2013-01-01
      • 2012-09-10
      • 2020-07-31
      • 1970-01-01
      • 1970-01-01
      • 2017-07-31
      相关资源
      最近更新 更多