我是Android的新手,一直在寻找解决方案,但迄今为止没有运气。我想创建一个布局,就像下面的图片一样。
我想要一个大小与屏幕相同的LinearLayout。然后有另一个大小也与屏幕相同但不在屏幕上的LinearLayout。我可以在这两个虚拟“屏幕”之间滚动。
有一篇有趣的文章讲解了如何扩展scrollView类,以便我可以获得炫酷的捕捉效果,因此,如果我能使其工作,我的应用程序将感觉就像在主屏幕之间滚动。
我已经了解了权重和scrollView的fillViewport =“true”,但我害怕我不知道如何使用这些东西来让horizontalScrollView填充屏幕。我尝试过各种fill_parent和wrap_content的组合,但都无济于事。
在我看来,只要针对屏幕可变性构建子视图(每个“屏幕”中的元素),这个功能就不会损害在不同屏幕设备之间的应用程序可移植性。
这是我尝试的XML的简单示例:
<HorizontalScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/HorizontalScrollView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/txtTestBox"
>
</EditText>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 1"
/>
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
很不幸,那甚至不能接近我要找的东西。希望这可以实现...
感谢任何帮助或建议。