Android XML布局:让图像视图直接位于底部

Android XML布局:让图像视图直接位于底部,android,xml,android-layout,Android,Xml,Android Layout,我正在尝试创建一个应用程序,它有一个充满按钮的滚动视图和底部的图像视图。唯一的问题是我不能让图像视图直接停留在底部。我试着将layout_gravity和gravity设置到底部,但图像不在屏幕上。我不想使用重量,因为有自定义按钮,它会扭曲它们。我尝试了相对布局和框架布局,但没有成功,我可能没有正确使用它们。通过此设置,底部在顶部可见,但在底部不可见 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:a

我正在尝试创建一个应用程序,它有一个充满按钮的滚动视图和底部的图像视图。唯一的问题是我不能让图像视图直接停留在底部。我试着将layout_gravity和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>

您可以使用relativeLayout环绕imagevire和scrollview。然后在XML中指定属性:alignparentbottom=true和Upper=your_imageview用于scrollview,alignparentbottom=true和Down=your_scrollview用于imageview。

尝试使用线性布局而不是相对线布局

我知道你不想使用android:gravity=bottom,但如果你这样做,并将高度设置为android:height=wrap\u content,则不会扭曲图像。

添加 将android:weightSum=10添加到顶部线性布局中。 然后将android:weight=7添加到ImageView,将android:weight=3添加到ScrollView。
更改这些视图的高度和宽度以填充父视图

您所说的“底部在顶部可见而不是底部可见”是什么意思?