m5 / MagicTextView

Other
243 stars 102 forks source link

Inner shadow doesn't work on SDK 14+ #3

Closed pdalfarr closed 10 years ago

pdalfarr commented 12 years ago

Inner shadow doesn't work when client project SDK is 14 or above (project using your library project). Changing the SDK level of the MagicTextView project to 14+ also 'deactivate' the innershadow feature.

SDK version up to 13 are ok

I suspect some other feature to be also impacted by this, but I didn't really had the time to check.

Anyway, this is really a great stuff you did :-)

Note: FYI, shadows are visible in eclipse, whatever the SDK level is.

Shusshu commented 12 years ago

It works on API 15 but not on 16

cosic commented 11 years ago

Just use advice:

"Realistically, just copy MagicTextView.java & attrs.xml into your project and use them as your own."

And futher follow:

  1. rename "backgroud" attribute at attrs.xml and MagicTextView.java.
  2. rename "xmlns:qwerjk="http://schemas.android.com/apk/res/com.qwerjk.better_text" with use your package project name. For example: "xmlns:qwerjk="http://schemas.android.com/apk/res/com.my.package"

It's worked, I checked.

kwent commented 11 years ago

+1 it works

Gilianp commented 11 years ago

The problem is that inner shadow are drawn by using PorterDuffXfermode, and many of this operations are not supported be hardware accelerated (new APIs have this as default). So, you should disable hardware acceleration for these type of views.

in init() method you should put:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}

this solved all my problems in all levels of API

m5 commented 10 years ago

I've implemented @Gilianp's fix. Thanks!