Note that there are some explanatory texts on larger screens.

plurals
  1. POhardware accelerated webview slide-in animation flickering on ICS
    primarykey
    data
    text
    <p>Our application makes heavy use of webviews. When testing on ICS, we noticed that we need to set the application property <code>hardwareAccelerated="true"</code>. However, doing this caused a few other bugs in our application, most of which we have fixed. We are still having problems getting our 'slide-in' animation working. Without any code changes, the animation simply does a 'reveal' type animation rather than sliding. We have tries a few different things:</p> <ol> <li>Adding a small alpha transition (.99->1). This changes the 'reveal' to a 'slide' but causes some weird artifacts on the screen sometimes.</li> <li>using hardware layers during the animation. This doesn't work consistently.</li> <li>using software layers during the animation. This works, but causes a slow redraw after the slide-in animation completes for the first time.</li> </ol> <p>Approach 3 is the most promising, but we have not figured out how to avoid the redraw. We have created a small test case using a sample project with a single activity:</p> <p>activity class:</p> <pre><code> int accelValue = View.LAYER_TYPE_NONE; //hack /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); addClickListenerAnimation(R.id.buttonhl, R.anim.to_left, View.VISIBLE, View.INVISIBLE); addClickListenerAnimation(R.id.buttonhr, R.anim.to_right, View.VISIBLE, View.INVISIBLE); addClickListenerAnimation(R.id.buttonsl, R.anim.from_left, View.INVISIBLE, View.VISIBLE); addClickListenerAnimation(R.id.buttonsr, R.anim.from_right, View.INVISIBLE, View.VISIBLE); final Button b = (Button) findViewById(R.id.accel); b.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { accelValue = ++accelValue % 3; b.setText(accelValue == 0 ? "NONE" : accelValue == 1 ? "S/W" : "H/W"); } }); } private void addClickListenerAnimation(int buttonId, final int animId, final int startVis, final int endVis) { Button b = (Button) findViewById(buttonId); b.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { final WebView wv = (WebView) findViewById(R.id.webview); final View layout = findViewById(R.id.frame); Animation a = AnimationUtils.loadAnimation(getApplicationContext(), animId); a.setDuration(500); a.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { Log.i("sb", "layer type was " + wv.getLayerType()); Log.i("sb", "llayout layer type was " + layout.getLayerType()); wv.setLayerType(accelValue, null); Log.i("sb", "setting layer type " + accelValue); } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { wv.setLayerType(View.LAYER_TYPE_NONE, null); Log.i("sb", "restoring layout layer type " + layout.getLayerType()); } }); layout.setAnimation(a); layout.setVisibility(endVis); } }); } @Override protected void onStart() { super.onStart(); ((WebView)findViewById(R.id.webview)).loadUrl("http://www.wikipedia.org"); } </code></pre> <p>from_left.xml animation (other animation xmls are similar):</p> <pre><code>&lt;set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="true"&gt; &lt;translate android:fromXDelta="-100%" android:toXDelta="0%" android:fromYDelta="0%" android:toYDelta="0%" android:duration="600" android:zAdjustment="bottom" /&gt; &lt;/set&gt; </code></pre> <p>main.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/llayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;FrameLayout android:id="@+id/frame" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:visibility="invisible" &gt; &lt;WebView android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/&gt; &lt;/FrameLayout&gt; &lt;View android:layout_width="fill_parent" android:layout_height="80dp" android:background="#FF000000" /&gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="80dp" android:orientation="horizontal" &gt; &lt;Button android:id="@+id/buttonsl" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="show L" /&gt; &lt;Button android:id="@+id/buttonhl" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="hide L" /&gt; &lt;Button android:id="@+id/buttonsr" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="show R" /&gt; &lt;Button android:id="@+id/buttonhr" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="hide R" /&gt; &lt;Button android:id="@+id/accel" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="NONE" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>manifest:</p> <pre><code>&lt;uses-sdk android:minSdkVersion="14" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload