Enable scroll

Put your problem here if it does not fit any of the other categories.

Enable scroll

Postby solo » Fri Apr 01, 2011 10:38 pm

Hello Android people,

This might be a retarded question:
I am creating my first application, and I can not scroll inside the application. How come vertical scroll is disabled?

main.xml
Code: Select all
<?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:background="@drawable/bg_texture"

    android:orientation="vertical">
   
    <ImageView
    android:layout_height="wrap_content"
    android:id="@+id/imageView1"
    android:src="@drawable/logo"
    android:layout_width="fill_parent"
    android:paddingTop="8dip"
   android:paddingBottom="20dip"></ImageView>

    <Button android:text="Bake"
        android:id="@+id/MainCategoryBake"
        android:layout_width="fill_parent"
        android:textSize="14px"
        android:layout_height="49px"
        android:background="@drawable/button_bg"
        android:textColor="#ffffff"
        android:typeface="sans">
    </Button>   
   
    <Button android:text="Foretter"
        android:id="@+id/MainCategoryForetter"
        android:layout_width="fill_parent"
        android:textSize="14px"
        android:layout_height="49px"
        android:background="@drawable/button_bg"
        android:textColor="#ffffff"
        android:typeface="sans">
    </Button>   
   
    <Button android:text="Hovedretter"
        android:id="@+id/MainCategoryHovedretter"
        android:layout_width="fill_parent"
        android:textSize="14px"
        android:layout_height="49px"
        android:background="@drawable/button_bg"
        android:textColor="#ffffff"
        android:typeface="sans">
    </Button>   
   
    <Button android:text="Søk"
        android:id="@+id/MainCategorySok"
        android:layout_width="fill_parent"
        android:textSize="14px"
        android:layout_height="49px"
        android:background="@drawable/button_bg"
        android:textColor="#ffffff"
        android:typeface="sans">
    </Button>   
   

</LinearLayout>
~ Asking if computers can think is like asking if submarines can swim.
User avatar
solo
Junior Developer
Junior Developer
 
Posts: 22
Joined: Fri Mar 25, 2011 9:51 pm

Top

Re: Enable scroll

Postby Faded9 » Sat Apr 02, 2011 3:01 am

There's nothing telling it you want to scroll.

Put your current XML inside of a ScrollView and it should instantly give you the basic scroll you're looking for. If there's a problem post back and I will look into it a bit more for you.
Faded9
Junior Developer
Junior Developer
 
Posts: 16
Joined: Tue Mar 22, 2011 7:14 pm

Re: Enable scroll

Postby solo » Mon Apr 04, 2011 11:06 pm

Thank you, I got it working now.

My new main.xml:
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scroller"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true" >

   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:background="@drawable/bg_texture"
       android:orientation="vertical">
   
       <ImageView
       android:layout_height="wrap_content"
       android:id="@+id/imageView1"
       android:src="@drawable/logo"
       android:layout_width="fill_parent"
       android:paddingTop="8dip"
      android:paddingBottom="20dip"></ImageView>

       <Button android:text="Bake"
            android:id="@+id/MainCategoryBake"
           android:layout_width="fill_parent"
           android:textSize="14px"
           android:layout_height="49px"
           android:background="@drawable/button_bg"
              android:textColor="#ffffff"
           android:typeface="sans">
       </Button>   
   
       <Button android:text="Foretter"
           android:id="@+id/MainCategoryForetter"
           android:layout_width="fill_parent"
           android:textSize="14px"
           android:layout_height="49px"
           android:background="@drawable/button_bg"
           android:textColor="#ffffff"
           android:typeface="sans">
       </Button>   
   
         <Button android:text="Hovedretter"
           android:id="@+id/MainCategoryHovedretter"
           android:layout_width="fill_parent"
           android:textSize="14px"
           android:layout_height="49px"
           android:background="@drawable/button_bg"
           android:textColor="#ffffff"
           android:typeface="sans">
       </Button>   
   
         <Button android:text="Småretter"
           android:id="@+id/MainCategorySmaaretter"
           android:layout_width="fill_parent"
           android:textSize="14px"
           android:layout_height="49px"
           android:background="@drawable/button_bg"
           android:textColor="#ffffff"
           android:typeface="sans">
       </Button>
   
       <Button android:text="Søk"
           android:id="@+id/MainCategorySok"
           android:layout_width="fill_parent"
           android:textSize="14px"
           android:layout_height="49px"
           android:background="@drawable/button_bg"
           android:textColor="#ffffff"
           android:typeface="sans">
       </Button>   
   
       <Button android:text="Next"
             android:id="@+id/Button01"
           android:layout_width="fill_parent"
           android:textSize="14px"
           android:layout_height="49px"
           android:background="@drawable/button_bg"
           android:textColor="#ffffff"
           android:typeface="monospace">
      </Button>   
   </LinearLayout>
</ScrollView>
~ Asking if computers can think is like asking if submarines can swim.
User avatar
solo
Junior Developer
Junior Developer
 
Posts: 22
Joined: Fri Mar 25, 2011 9:51 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 23 guests