スライドインナビゲーション(Facebook、Path、またはGoogle+のAndroidアプリ)を実装しようとしています。このバグを再現する完全なソースcan be found here。デバイスの表示をアニメートするときにAndroid WebViewのちらつきのバグが発生する
WebView
を画面からアニメーション化すると、デバイス上で、デバイスが画面から押し出す直前にWebView
のかわりにちらつきが発生しているように、ちらつきが発生します。
アーティファクトは、エミュレータ上では発生しません!アニメーションは円滑に進みます。
興味深いことに、このちらつきがアニメ化されたビューがWebView
である場合にのみ発生するようです!ここでは、メインのコンテンツビューとしてTextViewを使用する同じプロジェクトがあります。
ウェブビュー・アクティビティのレイアウト:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/blue" >
<WebView
android:id="@+id/web_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
</RelativeLayout>
とテキストビュー・アクティビティのために:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/blue" >
<TextView
android:id="@+id/web_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello there. no flicker!"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
/>
</RelativeLayout>
コードでナビゲーションメニューをスライドさせると呼ばれる:
private void slideIn() {
LinearLayout actionBarFrame = (LinearLayout) findViewById(android.R.id.content).getParent();
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
menuView = inflater.inflate(R.layout.menu, null);
menuView.setLayoutParams(new FrameLayout.LayoutParams(SIZE, LayoutParams.MATCH_PARENT, Gravity.LEFT));
FrameLayout decorView = (FrameLayout) getWindow().getDecorView();
decorView.addView(menuView);
decorView.bringChildToFront(actionBarFrame);
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) actionBarFrame.getLayoutParams();
params.setMargins(SIZE, 0, -SIZE, 0);
actionBarFrame.setLayoutParams(params);
TranslateAnimation ta = new TranslateAnimation(-SIZE, 0, 0, 0);
ta.setDuration(DURATION);
actionBarFrame.startAnimation(ta);
}
アウト戻ってそれをスライドさ:
private void slideOut() {
LinearLayout actionBarFrame = (LinearLayout) findViewById(android.R.id.content).getParent();
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) actionBarFrame.getLayoutParams();
params.setMargins(0, 0, 0, 0);
actionBarFrame.setLayoutParams(params);
TranslateAnimation ta = new TranslateAnimation(SIZE, 0, 0, 0);
ta.setDuration(DURATION);
ta.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation arg0) {
((FrameLayout) getWindow().getDecorView()).removeView(menuView);
menuView = null;
}
@Override public void onAnimationRepeat(Animation arg0) { }
@Override public void onAnimationStart(Animation arg0) { }
});
actionBarFrame.startAnimation(ta);
}
私が持っているとおりに、このプロジェクトを試すことができますので、私は公共のレポとしてBitBucketにコードをアップロードしました。
これがなぜ起こっているのか、それを修正する方法についての助力やアイデアは非常に高く評価されます!望むのは、WebView
を滑らかにアニメーション化して画像の外に出して戻すことです。ありがとう!
ここで同じ問題が発生します。 @ロベルトあなたはこれのための解決策を見つけましたか? – jayellos
@jayellosこの問題には2つの潜在的な修正があります。私は以下の答えを追加しますが、この物語の道徳は、WebViewでハードウェアアクセラレーションを有効にすると(デフォルトでは一部のプラットフォームでは有効にならない)、[このライブラリ](https:// github。 com/jfeinstein10/SlidingMenu)(現在のソリューション) –