Android-屏幕底部的布局始终位于前景

Android-屏幕底部的布局始终位于前景,android,android-layout,Android,Android Layout,我的xml文件如下所示: <LinearLayout> <ScrollView> <LinearLayout> </LinearLayout> </ScrollView> </LinearLayout> 第一个LinearLayout具有android:layout\u height=“match\u parent”,所有其他的android:layout\u height=

我的xml文件如下所示:

<LinearLayout>
    <ScrollView>
       <LinearLayout>
       </LinearLayout>
    </ScrollView>
</LinearLayout>


第一个LinearLayout具有android:layout\u height=“match\u parent”,所有其他的
android:layout\u height=“wrap\u content”
。如何使用imageview在屏幕底部创建始终位于前景的布局?

您可以将线性布局的重心设置为底部

android:layout_gravity="bottom"
创建XML文档时,顺序很重要。例如:

<ImageView/>
<LinearLayout/>


线性布局将放置在ImageView的前面

这最好通过相对布局来完成。相对布局元素堆叠在彼此的顶部,除非您相对放置它们。例如,如果您有两个图像视图并对其进行了定位,则第二个图像视图将放置在第一个图像视图的顶部

下面是一个让您开始学习的示例:

<RelativeLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent">
     <ScrollView
      android:layout_width="match_parent"
      android:layout_height="match_parent">
         <LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"/>
     </ScrollView>
     <ImageView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_alignParentBottom="true"
      android:contentDescription="@string/YOUR_CONTENT_DESC"
      android:scaleType="fitXY"
      android:src="@drawable/ic_launcher"/>
</RelativeLayout>

试试这种方法,希望这能帮助你用另一种方法解决问题。

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        </LinearLayout>
    </ScrollView>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher"
        android:adjustViewBounds="true"
        android:layout_gravity="bottom|center_horizontal"/>
</FrameLayout>


我不明白你的问题,但这可能对你有用吗<代码>我需要一个布局,相对的或线性的,因为我不需要一个简单的图像视图。。。有什么想法吗?没用。我在下面添加了带有android:layout_gravity=“bottom”的linearlayout,linearlayout显示在滚动视图下方,而不是屏幕底部。您是否尝试将linearlayout放置在滚动视图内部?linearlayout必须始终位于前景中。它应该仍然位于前景中。。。在scrollview内部不应该影响这一点。我已经尝试使用RelativeLayout更改第一个LinearLayout,我在屏幕底部放置了一个LinearLayout,scrollview不再工作。我在许多屏幕底部有按钮的应用程序中都这样做了。滚动视图中的线性布局是您放置要滚动的内容的位置。没错,滚动视图后的线性布局与RelativeLayout正确工作。非常感谢,您能否编辑您的答案,将ImageView置于线性布局中,以供将来对该问题感兴趣的人使用?