activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<WebView
android:id="@+id/upperview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<WebView
android:id="@+id/lowerview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
MainActivity.java
package com.example.urano_joji.test1;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView upperView = (WebView)findViewById(R.id.upperview);
upperView.loadUrl("file:///android_asset/android.jpg");
}
}
これを追加
build.gradle
android {
sourceSets{
main{
assets.srcDirs = ['htmlSource']
}
}
}
appの下にhtmlSourceというディレクトリを追加