android:layout\u alignParentBottom=“true”和android:gravity=“bottom”但是xml项仍然显示在顶部
我不确定这到底是为什么发生的,但我在我的android xml布局中指定了android:layout\u alignParentBottom=true和android:gravity=bottom,但是包含旋转木马1的项目HorizontalScrollView仍然显示在布局的顶部 我不确定在这种情况下到底出了什么问题 提前谢谢 截图: 在水平滚动视图中,不要使用layout\u alignParentBottom,请使用android:layout\u gravity=bottom LinearLayout为其子对象使用layout_gravity,RelativeLayout使用layout_alignX,其中X为顶部、底部等。如果需要,可以将其保留为layout_alignParentBottom,但HorizontalScrollView的父对象需要是RelativeLayout。任何一种解决方案都应达到相同的效果。尝试此布局android:layout\u alignParentBottom=“true”和android:gravity=“bottom”但是xml项仍然显示在顶部,android,xml,Android,Xml,我不确定这到底是为什么发生的,但我在我的android xml布局中指定了android:layout\u alignParentBottom=true和android:gravity=bottom,但是包含旋转木马1的项目HorizontalScrollView仍然显示在布局的顶部 我不确定在这种情况下到底出了什么问题 提前谢谢 截图: 在水平滚动视图中,不要使用layout\u alignParentBottom,请使用android:layout\u gravity=bottom Line
<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="wrap_content"
android:layout_marginBottom="00dp"
android:layout_marginTop="0dp"
android:background="@drawable/background_faded"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:background="#000000"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="20dip" >
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="0dp"
android:background="@drawable/background_faded"
android:orientation="vertical" >
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:scrollbars="none" >
<LinearLayout
android:id="@+id/carousel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" />
</HorizontalScrollView>
</LinearLayout>
</ScrollView>
</RelativeLayout>
我将父LinearLayout更改为RelativeLayout,并在ScrollView的LinearLayout中删除了android:layout\u alignParentBottom=true,只添加了android:layout\u gravity=bottom。我希望这对你有帮助。这是xml文件
<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="wrap_content"
android:layout_marginBottom="00dp"
android:layout_marginTop="0dp"
android:background="@drawable/background_faded"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:background="#000000"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="20dip" >
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/imageView1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:layout_marginTop="0dp"
android:background="@drawable/main_header_selector"
android:orientation="vertical" >
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:scrollbars="none" >
<LinearLayout
android:id="@+id/carousel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" />
</HorizontalScrollView>
</LinearLayout>
</ScrollView>
</RelativeLayout>
我按照你的建议试过了,但它仍然出现在屏幕的顶部。。。您还需要将LinearLayout中的layout_alignParentBottom以及下面的ScrollView layout_更改为layout_gravity=bottom。我会仔细检查这个结构是否会产生正确的输出并编辑我的答案。我也试过了。。。出于某种奇怪的原因,它仍然出现在顶部。我只是谢谢你!但是滚动视图/旋转木马仍然出现在布局的顶部…你能介绍一下这个布局是如何膨胀的吗?这是唯一用于复制链接图像的布局吗?例如,由于引用了此处不存在的“imageView1”id,因此您似乎有另一个布局
<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="wrap_content"
android:layout_marginBottom="00dp"
android:layout_marginTop="0dp"
android:background="@drawable/background_faded"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:background="#000000"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="20dip" >
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/imageView1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:layout_marginTop="0dp"
android:background="@drawable/main_header_selector"
android:orientation="vertical" >
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:scrollbars="none" >
<LinearLayout
android:id="@+id/carousel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" />
</HorizontalScrollView>
</LinearLayout>
</ScrollView>
</RelativeLayout>