1

Please help me in this code below :(

I am working on a grid view which should show 4 fixed number of rows in landscape mode. It should display data from an arraylist and should scroll horizontally. I used normal grid view and rotated it by 270. Then inside the grid cell I have used a single Text View which I had to rotate by 90 in order to show the text straight. I set the numColumns property to 4. So the expected is to show 4 rows with data from the arraylist. But I am not getting the grid cell displaying text properky in 4 rows. I am pasting the below xml code for gridview and the single customized xml containing the textview which is inside the gridcell. I tried changing all the properties of the grid view, scroll view and text view. But dont know whats wrong with this code.

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/textView_installed_app" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="top"
        android:orientation="vertical" >

        <GridView
            android:id="@+id/gridView"
            android:layout_width="wrap_content"
            android:layout_height="400dp"
            android:columnWidth="10dp"
            android:gravity="center"
            android:numColumns="4"
            android:rotation="270" >
        </GridView>
    </LinearLayout>
</ScrollView>

Customized TextView inside gridview cell:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
    android:layout_gravity="center_vertical|center_horizontal"
    android:layout_marginRight="10dp"
    android:id="@+id/textview_gridcell"
    android:layout_width="wrap_content"
    android:layout_height="150dp"
    android:rotation="90"        
    />

cool me
  • 11
  • 1
  • 2
    It is bad to put a GridView (or any scrollable view) in a ScrollView – tyczj Oct 08 '14 at 13:36
  • ya but i dint find a better way to make a horizontal scrollable grid view with fixed number of rows. Please suggest – cool me Oct 08 '14 at 13:39
  • 1
    you dont, a gridview is suppose to scroll vertical. The user expects things to preform the same way across apps, dont confuse them by changing the core functionality of how a gridview is suppose to work – tyczj Oct 08 '14 at 13:42
  • the requirement is to make fixed number of rows and horizontal scrolling. What can be used? the data should be from arraylist – cool me Oct 08 '14 at 13:47
  • look here http://stackoverflow.com/questions/5725745/horizontal-scrolling-grid-view – tyczj Oct 08 '14 at 13:49

0 Answers0