Reputation: 345
I have two ImageViews which I hope imageViewA is overlapped by imageViewB, and when user select a seekbar, the alpha value of imageViewB will change accordingly (e.g., becoming translucent and users can see part of imageViewA).
It supposes to be a easy coding task, however I found the performance is VERY slow in my Galaxy S6.
I have tried all setAlpha(int), setAlpha(float), and setImageAlpha(float), but get no hope. It seems the most related question post is App UI operations (setting alpha, setting margins, etc.) very slow on 4.4.4 compared to 4.0.3
However, this question is still open. Does anyone knows how to speed it up?
---- Here is some updates ----
The minimal code is just simple, in the seekbar callback I made
imageViewB.setAlpha(selectedAlphaValue);
The VERY slow means the fps is less than 1~2. I do hope I can get the alpha changed 10 times a second to make users feel comfortable. (BTW, I don't benchmark the delay of set alpha function because it is TOO SLOW, even my human eyes can notice it only changes 1~2 times per second)
Upvotes: 2
Views: 1227
Reputation: 345
Thanks Nikola,
ViewCompat.setLayerType(view, LAYER_TYPE_HARDWARE, null)
Is the right thing to do. It solve my problem like a charm.
Could you please post your reply as an answer, Nikola? So I can rate you as the correct answer.
Upvotes: 2