It's a simple demo for Horizontal Scroll View in Android.
1-Print Screen:
2-HorizontalScrollView.java
package com.example.horizontalscrollview; import android.os.Bundle; import android.app.Activity; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } }
3-activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <HorizontalScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="50dp" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button1" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button2" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button3" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button4" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button5" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button6" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button7" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button8" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button9" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button10" /> </LinearLayout> </HorizontalScrollView> </LinearLayout>
how to do it with the ScrollView?
ReplyDelete1-ImageView(not move from screen)
2-Button (move up from screen)
3-world (move with the Button)
4-ImageView(move with the Botton)
1-ImageView(not move from screen)
2-Button (move up from screen)
3-world (move with the Button)
4-ImageView(move with the Botton)
like this one by one
Means you want vertical scroll view? with below requirements-
Delete1-ImageView(not move from screen)
2-Button (move up from screen)
3-world (move with the Button)
4-ImageView(move with the Botton)
follow below link-
Deletehttp://www.androidhub4you.com/2013/05/simple-scroll-view-example-in-android.html
Nice one...
ReplyDeleteis it possible to rotate it in circular order.
ReplyDeletecircular means?
DeleteTry in your layout android:rotaion="270"
how can we add animations to it while horizontal scrolling.
ReplyDeleteapply some effect on touch gesture if it is needed..
Deletei have problem whit this i cant run that.
ReplyDeleteerror:This HorizontalScrollView layout or its LinearLayout parent is useless.
whats problem
That was not error warning only just ignore it...
DeleteAnd code should work as you can see screen shot are there..
Thanks,
ok thank you.
Deleteyour welcome!
Deletehello, do you know how can I use an Horizontal scroll view , but filled by a simple adapter?(like a grid view)
ReplyDeleteAny ideas?
By the way, what a nice job you have done with this blog and the tutorials!
Thanks & your welcome!
Deleteand for gridview inside Horizontal scroll you should use dynamic layout. it will help you.
Thanks!
hi
ReplyDeleteInstead of ScrollView i want to use SimpleGesture and onFling() method.
So that based on the velocity or speed of swipe i can scroll the buttons.
Can you tell me how can we do this?
Thanks
Please use swipe gesture then...
DeleteTry this link-
http://www.androidhub4you.com/2012/07/dynamic-swipe-view-demo-in-android.html
i am trying for text to scrol... how can i get tat ? could you help me ??
ReplyDeleteI think it is same just create textview instead of button. or any other issue?
DeleteHie Manish
ReplyDeleteI want to know how use viewflipper inside scrollview?
i did it but when i use scrollview with that at that time image can not flip right to left or vise versa.
any solution???
please let me now.
Hi Dhaval, I don't think it will work because view-flipper is touch gesture and scroll-view and list-view. so you can't put two touch gesture on same place.
DeleteSuch a nice job man !! Appreciate you !! :-)
ReplyDeletenice sir thanx for help us
ReplyDeletenice sir and thanx for help us
ReplyDeleteCan I replace button with list view? Will it work the same? I want list view with horizontal scrolling.
ReplyDeleteHi ! How can i set space between two views in horizontalscrollview?
ReplyDeleteJust add some space into your button-
Deleteandroid:layout_width="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_height="wrap_content"
android:text="Button1"
horizontalscrollview works on Samsung Galaxy S3 neo but doesn't on htc neither huawei. I don't understand why.Can you help me please?
ReplyDeletecan you please tell me how to implement multiple pages in a single layout under fragment??
ReplyDelete