我想通过布局实现以下结果:
1)大部分视图都是空的;
2)第一个元素位于屏幕可见的底部
3)通过向下滚动,第一个可用的元素如下。
有可能实现吗?
也许我可以通过顶部的空占位符来实现它?我如何填充屏幕上的所有可用空间,但不是要覆盖第一个元素?
答案 0 :(得分:0)
以下xml将在页面底部显示第一个元素,并且在滚动时可以访问下一个元素。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="30dp"
android:layout_alignParentBottom="true"
android:background="@android:color/darker_gray" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="TEXT1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="TEXT1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="TEXT1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="TEXT1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="TEXT1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="TEXT1" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
让我知道这可以解决您的问题: - )
答案 1 :(得分:0)
我设法使用第一个元素上的填充并将其移动到屏幕底部来实现此目的。在绘制初始布局并且所有视图的大小都已知之后,我必须以编程方式设置填充。