I want to set my webview under my gridview via xml. I want to look something like that But right now its look like this, webview is diagonal to gridview
This is my code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Contacts"
android:background="@drawable/gradient"
android:orientation="horizontal">
<GridView
android:layout_width="match_parent"
android:layout_height="450dp"
android:numColumns="2"
android:horizontalSpacing="4dp"
android:verticalSpacing="4dp"
android:id="@ id/gridView"
/>
<WebView
android:layout_width="match_parent"
android:layout_height="550dp"
android:layout_marginTop="180dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_below="@ id/gridView"
/>
</LinearLayout>
But i want to set the images from string array. For wxample
CodePudding user response:
You can use a RelativeLayout to achieve this.
First, add a WebView and a GridView to your layout. Then, set the GridView's layout_above attribute to the ID of the WebView.
<RelativeLayout>
<GridView
android:id="@ id/gridview"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<WebView
android:id="@ id/webview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_above="@id/gridview" />
</RelativeLayout>