hi I create an activity with relative layout/scrollview/gridlelayout but my application didnt open. what is my mistake? is not gridlelayout use within scrollview? hi I create an activity with relative layout/scrollview/gridlelayout but my application didnt open. what is my mistake? is not gridlelayout use within scrollview?
thanks alot.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="com.peg.MainActivity">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="1"
android:rowCount="1">
<Button
android:id="@+id/s"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_margin="20dp"
android:layout_row="0"
android:background="@drawable/s" />
<Button
android:id="@+id/hur"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_margin="20dp"
android:layout_row="1"
android:background="@drawable/hur" />
<Button
android:id="@+id/mil"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_margin="20dp"
android:layout_row="0"
android:background="@drawable/mil" />
<Button
android:id="@+id/ysr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_margin="20dp"
android:layout_row="1"
android:background="@drawable/ysr" />
</GridLayout>
</ScrollView>
</RelativeLayout>
Try this
you increase the android:columnCount="2"
and android:rowCount="2"
in Gridlayout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="2"
android:orientation="horizontal"
android:rowCount="2">
<Button
android:id="@+id/s"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_margin="20dp"
android:layout_row="0"
android:background="@mipmap/ic_launcher" />
<Button
android:id="@+id/hur"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_margin="20dp"
android:layout_row="1"
android:background="@mipmap/ic_launcher" />
<Button
android:id="@+id/mil"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_margin="20dp"
android:layout_row="0"
android:background="@mipmap/ic_launcher" />
<Button
android:id="@+id/ysr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_margin="20dp"
android:layout_row="1"
android:background="@mipmap/ic_launcher" />
</GridLayout>
</ScrollView>
</RelativeLayout>
OUTPUT