質問編集履歴
1
質問の仕方を変更。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
※タイトルも質問内容も分かりづらいかもしれませんが、ご協力お願いできますでしょうか。
|
2
|
-
|
2
|
+
指摘を頂いたので、書き方を修正しました。
|
3
3
|
■前提
|
4
4
|
・アプリの画面(MaingActivity)のレイウアトで、AndroidOS:5.0以上の場合は、Webkit.Webivewを利用し、5.0未満はCrosswalkを利用します。
|
5
5
|
・その他は全く同じレイアウト
|
@@ -7,19 +7,65 @@
|
|
7
7
|

|
8
8
|
|
9
9
|
|
10
|
-
■
|
10
|
+
■内容
|
11
|
+
以下のつくりを考えているのですが、Android経験者の方から見て、どうなのか指摘やアドバイスを頂けたらと思っています。
|
11
|
-
|
12
|
+
※こうした方が汎用的に使えるなど。
|
12
13
|
|
14
|
+
〇レイウアト
|
15
|
+
<?xml version="1.0" encoding="utf-8"?>
|
16
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
13
|
-
|
17
|
+
android:layout_width="match_parent"
|
18
|
+
android:layout_height="match_parent"
|
19
|
+
android:descendantFocusability="blocksDescendants"
|
14
|
-
|
20
|
+
android:orientation="vertical">
|
15
|
-
includeさせる。
|
16
21
|
|
17
|
-
→明細部はActivity.onCreate時に、OSのバージョンチェックをして、表示させる
|
18
|
-
コントールを制御する。
|
19
|
-
EX)androidOS:5.0以上:webkit.webviewのvisibility=visible
|
20
|
-
|
22
|
+
<!-- ヘッダー -->
|
23
|
+
<include layout="@layout/actionbar_custom" android:id="@+id/toolbar"/>
|
21
24
|
|
25
|
+
<!-- webkit.webview -->
|
26
|
+
<WebView
|
27
|
+
android:id="@+id/webView"
|
28
|
+
android:layout_width="match_parent"
|
22
|
-
|
29
|
+
android:layout_height="match_parent"
|
30
|
+
android:visibility="gone"/>
|
23
31
|
|
32
|
+
<org.xwalk.core.XWalkView
|
33
|
+
android:id="@+id/xwalkWebView"
|
34
|
+
android:orientation="vertical"
|
35
|
+
android:layout_width="match_parent"
|
36
|
+
android:layout_height="match_parent"/>
|
24
37
|
|
38
|
+
<!-- フッター -->
|
39
|
+
<fragment
|
40
|
+
android:id="@+id/tabBarFragment"
|
41
|
+
android:name="jp.co.pal_system.tabesoda.main.fragment.TabBarFragment"
|
42
|
+
android:layout_width="match_parent"
|
43
|
+
android:layout_height="@dimen/tabHeight"
|
44
|
+
/>
|
45
|
+
</LinearLayout>
|
46
|
+
|
47
|
+
〇MainActivity
|
48
|
+
// 画面項目
|
49
|
+
WebView topwebview;
|
50
|
+
XWalkView topXwalk;
|
51
|
+
|
52
|
+
・表示の切り分け判断
|
53
|
+
private void initWebView(){
|
54
|
+
if (WebViewUtil.isShowCrosswalk()){
|
55
|
+
// ■AndroidOS:5.0未満の場合
|
56
|
+
topXwalk = findViewById(R.id.topXwalkWebView);
|
57
|
+
topXwalk.setVisibility(View.VISIBLE);
|
58
|
+
|
59
|
+
}else{
|
60
|
+
// ■AndroidOS:5.0以上の場合
|
61
|
+
topwebview = findViewById(R.id.topWebView);
|
62
|
+
topwebview.setVisibility(View.VISIBLE);
|
63
|
+
topwebview.getSettings().setUseWideViewPort(true);
|
64
|
+
topwebview.getSettings().setLoadWithOverviewMode(true);
|
65
|
+
topwebview.getSettings().setJavaScriptEnabled(true);
|
66
|
+
topwebview.setWebViewClient(new CustomUrlHandleWebClient());
|
67
|
+
topwebview.addJavascriptInterface(new JavaScriptInterface(topwebview), "Apps");
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
25
|
-
上記のよう
|
71
|
+
※上記のように、すべてWebViewに関する処理をOSのバージョンによって、処理を切り分ける必要があるのですが、MainActivityですべて行うつくりを考えています。
|