Is it possible to make an EditText in android 2.x

2019-02-28 02:40发布

问题:

Is it possible to make an EditText in android 2.x that looks like an EditText from Android 4? I mean blue backlight with flanged edges below.

回答1:

Yes there is a library called holoeverywhere, you'll get all 4.2 components in 2.1+:

https://github.com/ChristopheVersieux/HoloEverywhere



回答2:

If you don't want to use an external library you can use the following code:

add the below code to res\values\styles.xml

<style name="HoloEditText">
    <item name="android:background">@drawable/edit_text_holo_dark</item>
</style>

After that from YOURPATH\android-sdk\platforms\android-16\data\res\ just copy the edit_text_holo_dark.xml and all referenced drawables to the corresponding directories in your project.

And then simply apply the style to your EditText:

 <EditText
   android:id="@+id/editText"
   style="@style/HoloEditText"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"/>