Android StudioにてCrossWalk(WebView)を使ってタブブラウザのようなものを作成しております。
FrameLayoutの中にWebViewを複数追加しておりますが、重なり順が変更されず困っております。
下記にActivityのレイアウトを記載させて頂きます。
XML
1<?xml version="1.0" encoding="utf-8"?> 2<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:app="http://schemas.android.com/apk/res-auto" 4 xmlns:tools="http://schemas.android.com/tools" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" 7 tools:context="MainActivity"> 8 9 <FrameLayout 10 android:id="@+id/frame" 11 android:layout_width="0dp" 12 android:layout_height="0dp" 13 app:layout_constraintBottom_toBottomOf="parent" 14 app:layout_constraintLeft_toLeftOf="parent" 15 app:layout_constraintRight_toRightOf="parent" 16 app:layout_constraintTop_toTopOf="parent"> 17 18 <org.xwalk.core.XWalkView 19 android:id="@+id/wkLayer1" 20 android:layout_width="match_parent" 21 android:layout_height="match_parent" /> 22 23 <org.xwalk.core.XWalkView 24 android:id="@+id/wkLayer2" 25 android:layout_width="match_parent" 26 android:layout_height="match_parent" /> 27 28 </FrameLayout> 29 30</android.support.constraint.ConstraintLayout>
この後にコードにてz-indexの変更を行っております。
Java
1 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 2 wkLayer1.setTranslationZ(1); 3 wkLayer1.setElevation(1.0f); 4 } 5 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 6 wkLayer2.setTranslationZ(2); 7 wkLayer2.setElevation(2.0f); 8 } 9 10 //切替の際下記コードを呼んでみても変わりませんでした。 11 wkLayer2.bringToFront(); 12 frame.requestLayout(); 13 frame.invalidate();
こちらのコードを実行するとwkLayer2が前面に表示されると思うのですが、wkLayer1が表示されてしまいます。
デバッグ環境
Android Studio 2.3.3
シミュレーター Nexus 5X API19 API 21 API 24(全てのバージョンで駄目でした)
何故かAndroid 4.2.2 API17の実機では意図したとおりに動いています。
何か解決方法や良い方法をご存じの方いらっしゃいませんでしょうか。
よろしくお願い致します。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/09/13 00:18