Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a layout to be scrollable ? Android

Hi I am trying to create a layout which is going to contain a couple of image views a button and some text but the problem is that the layout is not scrollable. any idea of how I could implement that ? Many thanks in advance.

<?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" >

   <ImageView
    android:id="@+id/imageView1"
    android:layout_width="match_parent"
    android:layout_height="204dp"
    android:scaleType="fitXY"
    android:src="@drawable/pic11elit" android:contentDescription="ss"/>

   <TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="whatever"
    android:textAppearance="?android:attr/textAppearanceLarge" />

   <TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:textAppearance="?android:attr/textAppearanceMedium" />

  <TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Reservation No :27210 10020"
    android:textAppearance="?android:attr/textAppearanceMedium" />
         <Button
    android:id="@+id/On_back"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="73dp"
    android:layout_height="wrap_content"
    android:onClick="On_back"
    android:text="back" />
      </LinearLayout>
like image 650
Nikolas Avatar asked Dec 16 '22 00:12

Nikolas


1 Answers

Try as below...

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="204dp"
            android:contentDescription="ss"
            android:scaleType="fitXY"
            android:src="@drawable/ic_launcher" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="whatever"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Reservation No :27210 10020"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <Button
            android:id="@+id/On_back"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="73dp"
            android:layout_height="wrap_content"
            android:onClick="On_back"
            android:text="back" />
    </LinearLayout>

</ScrollView>
like image 82
Hamid Shatu Avatar answered Dec 17 '22 14:12

Hamid Shatu