HorizontalScrollView not working on emulator

I'm rather new to android development and I'm completley stumped by what may be a very simple process.

I have set up a horizontal scroll view containing a series of ImageViews (acting as buttons) within a linearlayout. However when I run the project on the emulator only the first imageview is vissable and I cannot scroll horizontally through the other imageviews

I have searched extensivley across the net to find a solution but with no luck.

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


   <HorizontalScrollView 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    >

        <ImageView
            android:id="@+id/cookanegg"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:src="@drawable/cookanegg"
            android:text="@string/button_1"
            android:textSize="25dp"
            android:textStyle="bold" />

  <ImageView
      android:id="@+id/cheffytips"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:text="@string/button_2"
      android:textSize="25dp"
      android:textStyle="@drawable/chefstips" />

  <ImageView
      android:id="@+id/settings"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:text="@string/button_3"
      android:textSize="25dp"
      android:textStyle="@drawable/settings" /> 
    </LinearLayout>
    </HorizontalScrollView>  

What exactly am I missing?

Any help would be massively appreciated!!

Many Thanks,

Harrison

Answers


this is working for me in your horizontal scroll view give width:match_parent & hieght wrap_content

and inside scroll view use this

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/imv_new"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_weight="11.90"
            android:onClick="onClick"
            android:src="@drawable/newfile" />

        <ImageView
            android:id="@+id/imv_open"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_weight="11.90"
            android:onClick="onClick"
            android:src="@drawable/open" />

        <ImageView
            android:id="@+id/imv_save"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_weight="11.90"
            android:onClick="onClick"
            android:src="@drawable/save" />

        <ImageView
            android:id="@+id/imv_saveas"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_weight="11.90"
            android:onClick="onClick"
            android:src="@drawable/save_as" />



        <ImageView
            android:id="@+id/imv_delete"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_weight="11.90"
            android:onClick="onClick"
            android:src="@drawable/delete" />

        <ImageView
            android:id="@+id/imv_undo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_weight="11.90"
            android:onClick="onClick"
            android:src="@drawable/undo" />

        <ImageView
            android:id="@+id/imv_redo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_weight="11.90"
            android:onClick="onClick"
            android:src="@drawable/redo" />




        <ImageView
            android:id="@+id/imv_bold"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_weight="11.90"
            android:onClick="onClick"
            android:src="@drawable/bold" />

        <ImageView
            android:id="@+id/imv_italic"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_weight="11.90"
            android:onClick="onClick"
            android:src="@drawable/italic" />

        <ImageView
            android:id="@+id/imv_underline"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_weight="11.90"
            android:onClick="onClick"
            android:src="@drawable/underline" />



        <ImageView
            android:id="@+id/imv_l_margin"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_weight="11.90"
            android:onClick="onClick"
            android:src="@drawable/left" />

        <ImageView
            android:id="@+id/imv_m_margin"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_weight="11.90"
            android:onClick="onClick"
            android:src="@drawable/center" />

        <ImageView
            android:id="@+id/imv_r_margin"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_weight="11.90"
            android:onClick="onClick"
            android:src="@drawable/right" />




        <ImageView
            android:id="@+id/imv_exit"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_weight="11.90"
            android:onClick="onClick"
            android:src="@drawable/close" />
    </LinearLayout>

In Horizontall ScrollView i have taken Some images

Best Of Luck Aamirkhan I.


Make some changes like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <HorizontalScrollView
        android:id="@+id/ho"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/cookanegg"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_launcher"
                android:gravity="center"
                android:text="button_1"
                android:textSize="25dp"
                android:textStyle="bold" />

            <ImageView
                android:id="@+id/cheffytips"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:background="@drawable/ic_launcher"
                android:text="button_2"
                android:textSize="25dp" />

            <ImageView
                android:id="@+id/settings"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:background="@drawable/ic_launcher"
                android:text="button_3"
                android:textSize="25dp" />

            <ImageView
                android:id="@+id/settings"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:background="@drawable/ic_launcher"
                android:text="button_3"
                android:textSize="25dp" />

            <ImageView
                android:id="@+id/settings"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:background="@drawable/ic_launcher"
                android:text="button_3"
                android:textSize="25dp" />

            <ImageView
                android:id="@+id/settings"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:background="@drawable/ic_launcher"
                android:text="button_3"
                android:textSize="25dp" />

            <ImageView
                android:id="@+id/settings"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:background="@drawable/ic_launcher"
                android:text="button_3"
                android:textSize="25dp" />
        </LinearLayout>
    </HorizontalScrollView>

</LinearLayout>

I think you need to change your LinearLayout orientation to vertical.


Need Your Help

Where to put an application server in git / visual studio solution

git visual-studio visual-studio-2012

I have a visual studio solution with some (about 20) projects. Source control used for this solution is git.

Show first 4 elements from one array and first 1 element from another array, untill array elements exists

php arrays

I m trying to create a third array of numbers by showing the 4 first elements from first array and 1 first elements from the second array and so on.