-1

Working on Kotlin WebView,

val webView = WebView(this)
.....
webView.isHardwareAccelerated = true

returns compiler error ,

Val cannot be reassigned

How can I set isHardwareAccelerated = true for web view?

Update

This mod Rathod marked it as possibly duplicate and even closed the post without noticing the title of the post. I know when does this exception occurs. What I don't know is, how to modify the isHardwareAccelerated value on other way.

Community
  • 1
  • 1
Sazzad Hissain Khan
  • 37,929
  • 33
  • 189
  • 256
  • @NileshRathod please read the post carefully before marking as duplicated. I know when this exception occurs, what I don't know is how to change the `isHardwareAccelerated` value on other way. – Sazzad Hissain Khan Jun 27 '19 at 12:17
  • Check the doc https://developer.android.com/guide/topics/graphics/hardware-accel#view-level – Rodrigo Queiroz Jun 27 '19 at 16:57
  • @RodrigoQueiroz I have used `setLayerType()` as per documents suggestion but my `webView.isHardwareAccelerated` still returning false. Do you know why? – Sazzad Hissain Khan Jun 28 '19 at 04:54

1 Answers1

0

Try this :

webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);

Good luck!

Ilya Demidov
  • 3,275
  • 2
  • 26
  • 38