0 Replies - 3079 Views - Last Post: 23 July 2012 - 02:37 AM

#1 nehajagat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 19-July 12

Android horizontal scroll with bounce effect and numbering pages.

Posted 23 July 2012 - 02:37 AM

Hello, I am a fresher and completely new to android and hence i am stuck at these concepts which i will discuss now... 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:


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android";
xmlns:tools="http://schemas.android.com/tools";
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/back5" >
<ImageView
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" />
<!-- 1 -->
<HorizontalScrollView
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">

<LinearLayout
android:id="@+id/l1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|top"
android:orientation="horizontal" >

<ImageView
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"/>

<ImageView
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"/>

<ImageView
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"/>
</LinearLayout>
</HorizontalScrollView>

<!-- 2 -->

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

<LinearLayout
android:id="@+id/l2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|top"
android:orientation="horizontal" >

<ImageView
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"/>

<ImageView
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"/>


</LinearLayout>
</HorizontalScrollView>

<!-- 3 -->

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

<LinearLayout
android:id="@+id/l3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|top"
android:orientation="horizontal" >

<ImageView
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"/>

<ImageView
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"/>

<ImageView
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"/>


</LinearLayout>
</HorizontalScrollView>

<!-- 4 -->

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

<LinearLayout
android:id="@+id/l4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|top"
android:orientation="horizontal" >

<ImageView
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"/>

<ImageView
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"/>

</LinearLayout>
</HorizontalScrollView>

<!-- 5 -->

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

<LinearLayout
android:id="@+id/l5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|top"
android:orientation="horizontal" >

<ImageView
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" />

<ImageView
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" />

</LinearLayout>
</HorizontalScrollView>

</RelativeLayout>


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...

Thanks in advance :smartass:

This post has been edited by Atli: 23 July 2012 - 02:44 AM
Reason for edit:: Please use [code] tags when posting code.


Is This A Good Question/Topic? 0
  • +

Page 1 of 1