所以我正在尝试创建一个具有ListView的屏幕,我需要能够在屏幕的底部边缘浮动另一个自定义水平ListView。当用户在垂直列表视图上滚动时,水平的视图会在滚动停止时不可见并重新出现。我认为FrameLayout对于重叠视图来说是最好的选择。但我似乎无法做到这一点。水平列表视图似乎占据整个屏幕空间。有任何想法吗?这甚至是正确的方法吗?我希望在HTML中有类似于固定div的东西 这是我的XML:
UPDATE-1:按建议使用RelativeLayout,但仍然不行。 HorizontalListView似乎仍占据整个屏幕。我正在使用here
中的HorizintalListView<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ListView
android:id="@+id/messages"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="5dip" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<test.ui.app.HorizontalListView
android:id="@+id/folders"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF" />
</RelativeLayout>
</RelativeLayout>
答案 0 :(得分:2)
我通过自己设置内部相对布局的高度而不是使用'wrap_content'来实现它。
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ListView
android:id="@+id/messages"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="80dip"
android:layout_alignParentBottom="true" >
<test.ui.app.HorizontalListView
android:id="@+id/folders"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF" />
</RelativeLayout>
</RelativeLayout>
答案 1 :(得分:0)
您无法在 FrameLayout 之外调整视图。因此,您最好选择 RelativeLayout 。 或者您可以将列表视图放在RelativeLayout或linearlayout中,然后您可以进行调整。
希望这会对你有所帮助。 :)
答案 2 :(得分:0)
与其他回答者说的一样,你可以使用RelativeLayout:
或者,如果你真的想坚持使用FrameLayout(可能是出于性能原因......),你可以将一个巨大的android:layout_marginTop添加到水平列表视图中。但是这个解决方案更加丑陋,因为您需要设置准确的值。例如,如果整个屏幕的高度为320dp,并且您希望水平列表视图的高度为80dp,则需要将上边距设置为240dp。但是,如果在具有不同宽高比的屏幕上运行此操作,则水平列表视图将很难看。