How can i scroll the gridview horrizonally insted of vertically - android

I am doing a task which retrieves images from server and displays in GridView in the application. This Grid view is scrolling up and down. But i want to scroll this view left to right as the menu screen scrolls. Is it possible with grid view? Or Is there any better way to do this? please help me in doing this

Add this line in your gridview.
android:scrollbars="horizontal"
for ex:
<GridView
android:id="#+id/gridView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animationCache="true"
android:numColumns="3"
android:scrollbars="horizontal"
android:scrollingCache="false" >
</GridView>

Related

Android listview in scrollview, listview scroll when scrollview scrolled specific position

I need Scroll Listview inside Scrollview.
Scrollview has two child view, Relative layout and Listview
And listview is using naver's PullToRefresh library.
I want two function
When scroll-up, scroll about half of Relative layout, pass thru touch event to listview.
When scroll-down, if listview showing first item, realative layout will showing fully. else relative layout must be fixed scroll only listview. And if user had over scroll, pull-to-refresh must be work.
I have example screenshot
https://www.dropbox.com/s/8renmrmw5n8g5em/example.png?dl=0
It actually using in project, protected by NDA. that I censored it.
I had try to requestDisallowInterceptTouchEvent(), it not for me.
My layout xml.
<ScrollView
android:id="#+id/main_doc_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:fillViewport="true">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
layout="#layout/main_page_top_scroll_items"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
<com.handmark.pulltorefresh.library.PullToRefreshListView
xmlns:ptr="http://schemas.android.com/apk/res-auto"
android:id="#+id/main_doc_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#00000000"
android:divider="#00FF0000"
android:dividerHeight="0dp"
android:fadingEdge="none"
android:fastScrollEnabled="false"
android:footerDividersEnabled="false"
android:headerDividersEnabled="false"
android:smoothScrollbar="true"
android:scrollbars="none"
ptr:ptrFriction="3.0"
ptr:ptrSmoothScrollDuration="400" />
</LinearLayout>
</ScrollView>
Thank you for your kind cooperation.
solved.
I give up to use scroll view.
I using onScrollListener on Listview, change menu's marginTop realtime.

GridView: horizontal scroll does not work

I want to implement next:
in each row of grid view some nomber of visible elements, to reach other elements we can use horizontal scroll. But:
Code 1:
<GridView
android:id="#+id/gvTimeTape"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:columnWidth="100dp"
android:numColumns="30"
android:paddingLeft="200dp"
android:scrollbars="horizontal" >
</GridView>
Result (One row, all elements fit the screen):
Code 2:
<GridView
android:id="#+id/gvTimeTape"
android:layout_width="5000dp"
android:layout_height="wrap_content"
android:columnWidth="100dp"
android:numColumns="30"
android:paddingLeft="200dp"
android:scrollbars="horizontal" >
</GridView>
Result (elements not fit on the sreen and horizontall scroll not appears)
Does anybody knows in what trick?
Try to put your GridView to HorizontalScrollView.

How can i get Vertical scrolling in GridView android?

I am developing an android application with showing images. I am using grid view to show the images in my application.
But default gridview is horizontal scrolling I want to show the images in vertical scrolling grid view.
Please suggest me a way to achieve vertical scrolling in gridview.
Thanks in advance.
Use android:numColumns="3" // this will force gridview to have 3 columns and if you have more than 3 items in grid view, you can have vertical scrolling.
Ex.:
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/gridView1"
android:numColumns="3"
android:gravity="center"
android:columnWidth="50dp"
android:stretchMode="columnWidth"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</GridView>

Is it possible to set borders to grid view in android

Is it possible to set borders to grid view in xml. Like, i want each grid cell to contain borders. If so, kindly let me know how to do it. I have set this way. But i am not finding any specific thing to set border.
<GridView
android:layout_marginTop="95px"
android:layout_marginLeft="32px"
android:id="#+id/gridview"
android:layout_width="340px"
android:layout_height="250px"
android:columnWidth="35px"
android:numColumns="7"
android:scrollbars="none"
android:verticalSpacing="14px"
android:horizontalSpacing="18px"
android:stretchMode="columnWidth"
android:gravity="center_horizontal"
android:background="#color/white">
</GridView>
Thank you
Swathi

Getting a button to scroll into view at the bottom of a GridView on Android

I am trying to port an existing iPhone application to android. I wish to have a button scroll into view at the bottom of a GridView to enable the user to load more data from the server. Presently, my solution simply fixes a button at the bottom of the screen instead of having it scroll into view.
Here is my layout code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/grid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:columnWidth="70dp"
android:numColumns="auto_fit"
android:verticalSpacing="0dp"
android:horizontalSpacing="0dp"
android:stretchMode="columnWidth"
android:gravity="center"
android:background="#000000"
/>
<Button
android:id="#+id/load_more"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Load More"
/>
</LinearLayout>
Fixing the button at the bottom of the screen won't work because I plan on placing an ad at the bottom.
Can anyone either explain conceptually how to get a load more button to scroll into view, or point me to some sample code, OR tell me why this is not idiomatic to Android and what other UI convention it uses to load more data in a GridView?
Thanks!
You can place a ScrollView inside your main LinearLayout. A ScrollView can only have one direct child, though, so you'll need to put another LinearLayout inside of it which would then contain your GridView and Button.
I had a similar problem with scrolling a GridView and after refreshing the underlying data, noticing that the scoll was not reset to the beginning. I solved it with the following code fragment
gvKeys.setSelection(0);
I'm guessing that if you know the number of items in your grid, N, that the following will work:
gvKeys.setSelection(N);

Categories

Resources