I want to enable hardware acceleration for application.
I added in Android manifest line
<application
android:hardwareAccelerated="true"/>
I think this line should enable hardware acceleration on all view in the app, but when I check (using a method view.getLayerType()), I get a result of 0. I conclude that you are not using hardware acceleration
I don't understand how it works hardware acceleration.
Why if I turned hardware acceleration on the application level, all view in the application to call the method view.getLayerType() return 0 ?
I expect that should return 2, because I turned hardware acceleration on a higher level.
Isn't it so ?
For each view, it turns out you'll need to set the property android:layerType in xml ?
The tag you mentioned does turn on hardware acceleration on, but you only need it for API 13 or lower, as this is by default on on API version 14 and above.
To check whether your View (or Canvas, for custom views you are drawing) is using hardware acceleration or not, you can call
View.isHardwareAccelerated()
Canvas.isHardwareAccelerated()
getLayerType()
returns the layer type of a view, which as expected is NONE by default:
By default a view does not have a layer, and the layer type is LAYER_TYPE_NONE.
Also, keep in mind you should call isHardwareAccelearted()
after the view is attached to the window, to get the proper response. Prior to this the answer might not be correct.
Cheers