0

我正在尝试创建一个应用程序,该应用程序具有一个充满按钮的滚动视图和一个底部的图像视图。唯一的问题是我无法让图像视图直接留在底部。我尝试将 layout_gravity 和重力设置为底部,但图像不在屏幕上。我不想使用重量,因为有自定义按钮,它会扭曲它们。我已经尝试过相对布局和框架布局,但都无济于事(我可能没有正确使用它们)。使用此设置,底部在顶部可见,但在底部不可见。

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

<ImageView
    android:layout_width="320.0dip"
    android:layout_height="50.0dip"
    android:src="@drawable/logopublic" />

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

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

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

            <FrameLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" >

                <Button
                    android:id="@+id/button1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/blue" />

                <Button
                    android:id="@+id/button2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:background="@drawable/red" />

                <Button
                    android:id="@+id/button3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="right"
                    android:background="@drawable/green" />
            </FrameLayout>

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="2.5dip"
                    android:gravity="center"
                    android:text="@string/button2"
                    android:textStyle="bold" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentLeft="true"
                    android:layout_marginLeft="15dp"
                    android:gravity="center"
                    android:text="@string/button1"
                    android:textStyle="bold" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentRight="true"
                    android:layout_marginRight="15dp"
                    android:gravity="center"
                    android:text="@string/button3"
                    android:textStyle="bold" />
            </RelativeLayout>

    </LinearLayout>

</ScrollView>

</LinearLayout>
4

3 回答 3

0

尝试使用 aLinearLayout而不是 a RelativeLayout

我知道你不想 user android:gravity="bottom",但如果你这样做并将高度设置为android:height="wrap_content"它不应该扭曲你的图像。

于 2014-06-10T14:20:39.983 回答
0

您可以使用 relativeLayout 来包围您的 imagevire 和滚动视图。然后在 XML 中指定属性: alignparentbottom="true" 和 above="your_imageview" 用于滚动视图和 alignparentbottom="true" 和 below="your_scrollview" 用于图像视图。

于 2012-05-05T01:03:00.270 回答
0

添加 add android:weightSum="10" 到顶部的线性布局。然后将 android:weight="7" 添加到 ImageView 和 android:weight=3 到 ScrollView。将这些视图的高度和宽度更改为 fill_parent

于 2015-03-28T11:55:05.963 回答