Can someone please help, I cant get this simple scolling feature
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>
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>
精彩评论