tags:

views:

86

answers:

1

I want to be able to have many button and objects in my project but they all wont fit on the screen at once so i would like the user to be able to scroll down and have more appear but i cant get it to work. I tried using ScrollView but it always throws me errors. Here is what I have so far. Please, any help would be great.

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout


android:id="@+id/widget0"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

xmlns:android="http://schemas.android.com/apk/res/android"
>

<TextView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="Hello World, tipcalc"
/>
<TextView

android:id="@+id/widget28"

android:layout_width="99px"

android:layout_height="17px"

android:text="Monthly Income"

android:layout_x="40px"

android:layout_y="32px"

>

</TextView>

<TextView

android:id="@+id/widget29"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Cable"

android:layout_x="40px"

android:layout_y="82px"

>

</TextView>

<TextView

android:id="@+id/widget30"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Internet"

android:layout_x="40px"

android:layout_y="132px"

>

</TextView>





<TextView

android:id="@+id/widget33"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Total To Pay"

android:layout_x="40px"

android:layout_y="302px"

>

</TextView>

<Button

android:id="@+id/btncalculate"

android:layout_width="87px"

android:layout_height="wrap_content"

android:text="Calculate"

android:layout_x="40px"

android:layout_y="182px"

>

</Button>

<Button

android:id="@+id/btnreset"

android:layout_width="86px"

android:layout_height="wrap_content"

android:text="Reset"

android:layout_x="140px"

android:layout_y="182px"

>

</Button>

<EditText

android:id="@+id/Monthly"

android:layout_width="wrap_content"

android:layout_height="35px"

android:text="100"

android:textSize="18sp"

android:layout_x="200px"

android:layout_y="22px"

>

</EditText>

<EditText

android:id="@+id/Internet"

android:layout_width="51px"

android:layout_height="36px"

android:text="10"

android:textSize="18sp"

android:layout_x="200px"

android:layout_y="72px"

>

</EditText>

<EditText

android:id="@+id/Cable"

android:layout_width="wrap_content"

android:layout_height="39px"

android:text="1"

android:textSize="18sp"

android:layout_x="200px"

android:layout_y="122px"

>

</EditText>


<TextView

android:id="@+id/txttotal"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text=""

android:layout_x="200px"

android:layout_y="302px"

>
</TextView>


</AbsoluteLayout>
A: 

Use relative layout instead of absolute layout . Here is a example from my own project.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LoginScrollView" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:background="#000000"
    android:fillViewport="true"
    >
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="14dp">

        <Button
            android:id="@+id/butt1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
        <Button
            android:id="@+id/butt2"
            android:layout_below="@+id/butt1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
        <Button
            android:id="@+id/butt3"
            android:layout_below="@+id/butt2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
        <Button
            android:id="@+id/butt4"
            android:layout_below="@+id/butt3"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>


</RelativeLayout>   
</ScrollView>
f0rz
[CODE]<?xml version="1.0" encoding="utf-8"?><ScrollView android:id="@+id/widget0" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"><RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="30dp">[/CODE]Thats what i have and it errors out when i run it on the emulator. Sorry for the real basic questions.
Disregard that post above, I try to run it with the set up you mentioned and all i get is the buttons mashed up at the top of the screen, Im sorry for the trivial qiestions but i have no idea how to fix this
I´ve added buttons to the RelativeLayout. When you are using RelativeLayout you have to define "where" your buttons should be ... otherwise they all will be mashed up at the same X Y position. In this case im using android:layout_below:"button id" .... try it!
f0rz
can u accept why answer please
f0rz