The XML:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="8">
<TextView
android:id="@+id/textView_atXML"
android:layout_width="match_parent"
android:layout_height="0"
android:layout_weight="2"
android:textAlignment="center"
android:textSize="18sp" />
<WebView
android:id="@+id/webView_atXML"
android:layout_width="match_parent"
android:layout_height="0"
android:layout_weight="6"/>
</LinearLayout>
The Activity:
public class MainActivity extends AppCompatActivity {
TextView textView;
WebView webView;
String html;
String urlImage;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView=findViewById(R.id.textView_atXML);
webView=findViewById(R.id.webView_atXML);
html = "<h2><i>Title</i></h2><img src='https://www.w3schools.com/w3css/img_forest.jpg'><p>Description here</p>";
urlImage="https://www.w3schools.com/w3css/img_forest.jpg";
textView.setText(html);
webView.loadUrl(urlImage);
}
}
And in the manifest you must to ask permission to use internet connection:
<uses-permission android:name="android.permission.INTERNET" />