Jump to content
Android Forum - A Community For Android Users and Enthusiasts

Android horizontal scroll view with bounce effect & numbering pages as user scrolls the text


nehajagat
 Share

Recommended Posts

Hello,I am a fresher and completely new to android and i am stuck at few things... I will explain in detail to what i need exactly ... I am developing an ebook app for tablets powered with android OS (3.0) [iDE - eclipse(Juno)]. This app named "ilpalazzo" is already there in apple market but now i have been given a task to do it in android. I am new to android and hence i am confused how to start with it.

 

1. I have a horizontal scroll view with a list of books(in image view). When i click the image view it enters into another activity with its content where the user can read the book. So what i need is, in apple when the user scrolls the horizontal scroll it over scrolls and when you leave it, it bounces back amazingly. Since i am fresher and completely new to android, i only know the little basics of android. I do not have any idea about the advanced concepts of making an horizontal scroll bounce. I have searhed in google regarding it but i could not find anything.I will send you my code and suggest me how to give the bounce back effect for each horizontal scroll containing a list of images.

 

2. Next thing is that when i click on an image view (book image) in the first activity, it enters into another activity with its content. So this content of book is in a text view with a vertical scroll and now as the user scrolls the text , page numbers should be displayed in a text view saying that "You are in page:1 of 5 "... something like this:1/50...2/50....I hope you have got an idea what i need.

 

CODE:

mainscreen.xml:

;

xmlns:tools="http://schemas.android.com/tools";

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@drawable/back5" >

android:id="@+id/img_sidelogo"

android:layout_width="200dp"

android:layout_height="fill_parent"

android:layout_alignParentBottom="true"

android:layout_alignParentLeft="true"

android:layout_alignParentTop="true"

android:adjustViewBounds="true"

android:contentDescription="@string/sidelogo"

android:scaleType="fitXY"

android:src="@drawable/sidelogo_new" />

android:id="@+id/h1"

android:layout_width="1500dp"

android:layout_height="wrap_content"

android:layout_toRightOf="@id/img_sidelogo"

android:fadingEdgeLength="30dp"

android:scrollbars="none"

android:overScrollMode="always">

 

android:id="@+id/l1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:gravity="center_vertical|top"

android:orientation="horizontal" >

 

android:id="@+id/book1"

android:layout_width="220dp"

android:layout_height="220dp"

android:adjustViewBounds="true"

android:scaleType="fitXY"

android:contentDescription="@string/imag"

android:src="@drawable/first_book"/>

 

android:id="@+id/book2"

android:layout_width="220dp"

android:layout_height="220dp"

android:adjustViewBounds="true"

android:scaleType="fitXY"

android:contentDescription="@string/imag"

android:src="@drawable/second_book"/>

 

android:id="@+id/book3"

android:layout_width="220dp"

android:layout_height="220dp"

android:adjustViewBounds="true"

android:scaleType="fitXY"

android:contentDescription="@string/imag"

android:src="@drawable/third_book"/>

 

android:id="@+id/h2"

android:layout_width="1500dp"

android:layout_height="wrap_content"

android:layout_toRightOf="@id/img_sidelogo"

android:layout_below="@id/h1"

android:fadingEdgeLength="30dp"

android:scrollbars="none"

android:overScrollMode="always">

 

android:id="@+id/l2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:gravity="center_vertical|top"

android:orientation="horizontal" >

 

android:id="@+id/book4"

android:layout_width="400dp"

android:layout_height="230dp"

android:adjustViewBounds="true"

android:scaleType="fitXY"

android:contentDescription="@string/imag"

android:src="@drawable/fourth_book"/>

 

android:id="@+id/book5"

android:layout_width="220dp"

android:layout_height="230dp"

android:adjustViewBounds="true"

android:scaleType="fitXY"

android:contentDescription="@string/imag"

android:src="@drawable/fifth_book"/>

 

 

 

 

android:id="@+id/h3"

android:layout_width="1500dp"

android:layout_height="wrap_content"

android:layout_toRightOf="@id/img_sidelogo"

android:layout_below="@id/h2"

android:fadingEdgeLength="30dp"

android:scrollbars="none"

android:overScrollMode="always">

 

android:id="@+id/l3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:gravity="center_vertical|top"

android:orientation="horizontal" >

 

android:id="@+id/book7"

android:layout_width="400dp"

android:layout_height="230dp"

android:adjustViewBounds="true"

android:scaleType="fitXY"

android:contentDescription="@string/imag"

android:src="@drawable/seventh_book"/>

 

android:id="@+id/book8"

android:layout_width="220dp"

android:layout_height="230dp"

android:adjustViewBounds="true"

android:scaleType="fitXY"

android:contentDescription="@string/imag"

android:src="@drawable/eighth_book"/>

 

android:id="@+id/book9"

android:layout_width="400dp"

android:layout_height="230dp"

android:adjustViewBounds="true"

android:scaleType="fitXY"

android:contentDescription="@string/imag"

android:src="@drawable/ninth_book"/>

 

 

 

android:id="@+id/h4"

android:layout_width="1500dp"

android:layout_height="wrap_content"

android:layout_toRightOf="@id/img_sidelogo"

android:layout_below="@id/h3"

android:fadingEdgeLength="30dp"

android:scrollbars="none"

android:overScrollMode="always">

 

android:id="@+id/l4"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:gravity="center_vertical|top"

android:orientation="horizontal" >

 

android:id="@+id/book10"

android:layout_width="400dp"

android:layout_height="230dp"

android:adjustViewBounds="true"

android:scaleType="fitXY"

android:contentDescription="@string/imag"

android:src="@drawable/tenth_book"/>

 

android:id="@+id/book11"

android:layout_width="220dp"

android:layout_height="230dp"

android:adjustViewBounds="true"

android:scaleType="fitXY"

android:contentDescription="@string/imag"

android:src="@drawable/eleventh_book"/>

 

 

 

android:id="@+id/h5"

android:layout_width="1500dp"

android:layout_height="wrap_content"

android:layout_toRightOf="@id/img_sidelogo"

android:layout_below="@id/h4"

android:fadingEdgeLength="30dp"

android:scrollbars="none"

android:overScrollMode="always">

 

android:id="@+id/l5"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:gravity="center_vertical|top"

android:orientation="horizontal" >

android:id="@+id/book12"

android:layout_width="225dp"

android:layout_height="257dp"

android:adjustViewBounds="true"

android:contentDescription="@string/imag"

android:scaleType="fitXY"

android:src="@drawable/twelfth_book" />

android:id="@+id/book13"

android:layout_width="225dp"

android:layout_height="match_parent"

android:adjustViewBounds="true"

android:contentDescription="@string/imag"

android:scaleType="fitXY"

android:src="@drawable/thirteenth_book" />

 

 

MainActivity:

package com.usdi.ilpalazzo;

import android.os.Bundle;

import android.app.Activity;

import android.content.Intent;

import android.view.View;

import android.widget.ImageView;

 

public class MainActivity extends Activity

{

 

ImageView book1,book2,book3,book4,book5;

@Override

public void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.mainscreen);

 

 

book1=(ImageView)findViewById(R.id.book1);

book2=(ImageView)findViewById(R.id.book2);

book3=(ImageView)findViewById(R.id.book3);

book5=(ImageView)findViewById(R.id.book5);

 

book1.setOnClickListener(new View.OnClickListener()

{

public void onClick(View v)

{

Intent i1=new Intent(getApplicationContext(),Book1.class);

startActivity(i1);

finish();

}

});

 

book2.setOnClickListener(new View.OnClickListener()

{

 

public void onClick(View v)

{

// TODO Auto-generated method stub

Intent i2=new Intent(getApplicationContext(),Book2.class);

startActivity(i2);

}

});

 

book3.setOnClickListener(new View.OnClickListener()

{

public void onClick(View v)

{

Intent i3=new Intent(getApplicationContext(),Book3.class);

startActivity(i3);

 

}

});

 

book5.setOnClickListener(new View.OnClickListener()

{

public void onClick(View v)

{

Intent i5=new Intent(getApplicationContext(),Book5.class);

startActivity(i5);

 

}

});

 

 

}

 

}

 

Kindly help me with it... I do not know how to proceed after this in code...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...