Search code examples
androidandroid-layoutscrollviewandroid-linearlayoutandroid-scrollview

Scrolling functionality in android layout


In my application I want to provide functionality of scrolling entire layout on screen. Here i also wrapped Linearlayout within the ScrollView, but it doesn't provide scrolling facility. The following is my layout code :

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

<LinearLayout  
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:orientation="vertical"
  android:paddingTop="50dp"
  android:weightSum="1"
  android:layout_marginTop="67dp"
  >

    <ImageView 
        android:id="@+id/artistImageView"
        android:layout_width="fill_parent"
        android:layout_height="150dp"
        android:paddingTop="10dp"
        android:layout_marginTop="67dp"
        android:background="#000000"
    />

    <TextView
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:text="BIOGRAPHY"
        android:textColor="#eeeeee"
        android:background="#000000"
        android:id="@+id/txt1"
    />          
    <ImageView
        android:src="@drawable/separator_bio"
        android:scaleType="fitXY"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"            
        android:background="#000000"
        android:id="@+id/sep1"
    />                  
    <TextView  
        android:id="@+id/artistView" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"         
        android:textStyle="bold"
        android:textColor="#ffffff"              
        android:paddingLeft="10dp"
        android:paddingRight="5dp"        
        android:background="#000000"
    />
</LinearLayout>
</ScrollView>

Please suggest solution.Thanx.


Solution

  • This is the final code which worked for my application.

    <LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    <ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:id="@+id/ScrollView01"
        android:layout_marginTop="65dp"
        android:layout_marginBottom="163dp"
        android:background="#000000"
        android:scrollbarStyle="insideInset"
        >   
    <LinearLayout  
      android:layout_width="wrap_content"
      android:layout_height="250dp"
      android:orientation="vertical"  
      >
      <TextView android:id="@+id/artistName"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:textColor="#ffffff"
            android:textSize="16px"
      />
      <ImageView 
            android:id="@+id/artistImageView"   
            android:layout_width="fill_parent" 
            android:layout_height="150dp"        
            android:layout_marginTop="2dp"
            android:paddingTop="10dp"
            android:paddingLeft="100dp"
            android:background="#000000"
    
            android:layout_marginRight="50dp"
    
      />
    
        <TextView
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            android:text="BIOGRAPHY"
            android:textStyle="bold"
            android:textColor="#ffffff"
    
            android:background="#000000"
            android:id="@+id/txt1"
        />          
        <ImageView
            android:src="@drawable/separator_bio"
            android:scaleType="fitXY"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"            
            android:background="#000000"
            android:id="@+id/sep1"
            android:paddingBottom="2dp"
        />        
    
        <TextView  
            android:id="@+id/artistView" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"         
            android:textStyle="bold"
            android:textColor="#eeeeee"              
            android:paddingLeft="20dp"                       
            android:background="#000000"                        
            android:lines="25"
          android:layout_marginRight="-20dp"  
    
        />
    </LinearLayout>
    </ScrollView>
    </LinearLayout>