0

I added scrollview to a relative layout, but it scrolls more than I needed. If I remove the scrollview, it will not show the last two buttonImages. So I added srollview.

enter image description here

enter image description here

Here is the code.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >  


<RelativeLayout
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_image"
android:orientation="vertical">

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="58dp"
    android:src="@drawable/logo" />

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="40dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/imageView1"
    android:layout_marginTop="92dp"
    android:background="@drawable/button_layout"
    android:gravity="left|center_vertical"
    android:paddingLeft="25dp"
    android:text="Team Bio"
    android:textColor="#F8F8FF"
    android:textSize="30dp" />


<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="40dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/button1"
    android:layout_marginTop="15dp"
    android:background="@drawable/button_layout"
    android:gravity="left|center_vertical"
    android:paddingLeft="25dp"
    android:text="Contact Us"
    android:textColor="#F8F8FF"
    android:textSize="30dp" />


<Button
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="40dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/button2"
    android:layout_marginTop="14dp"
    android:background="@drawable/button_layout"
    android:gravity="left|center_vertical"
    android:paddingLeft="25dp"
    android:text="Facebook"
    android:textColor="#F8F8FF"
    android:textSize="30dp" />


<Button
    android:id="@+id/button4"
    android:layout_width="wrap_content"
    android:layout_height="40dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/button3"
    android:layout_marginTop="14dp"
    android:background="@drawable/button_layout"
    android:gravity="left|center_vertical"
    android:paddingLeft="25dp"
    android:text="Twitter"
    android:textColor="#F8F8FF"
    android:textSize="30dp" />


<Button
    android:id="@+id/button5"
    android:layout_width="wrap_content"
    android:layout_height="40dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/button4"
    android:layout_marginTop="14dp"
    android:background="@drawable/button_layout"
    android:gravity="left|center_vertical"
    android:paddingLeft="25dp"
    android:text="Youtube"
    android:textColor="#F8F8FF"
    android:textSize="30dp" />
</RelativeLayout>
</ScrollView>

I tried changing lots of things, but I can't make it work.

4

1 回答 1

2

会使用LinearLayout帮助吗?我不确定你需要一个RelativeLayout里面ScrollView只有那些按钮。

像这样的东西(额外的属性,ID等需要添加)......

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <LinearLayout
        android:background="@drawable/background_image"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <!-- Add buttons here... -->   

    </LinearLayout>
</ScrollView>

如果需要,它将滚动,否则不会滚动。

于 2012-07-25T20:24:29.373 回答