【发布时间】:2013-03-31 14:14:36
【问题描述】:
我有一个带有多个TextEdits 的活动,并且在纵向模式下,一切都完美显示。但是当我将设备切换到横向模式时,几个视图没有显示(它们被剪切)。我可以以某种方式自动添加当设备切换到横向模式时滚动到视图?
【问题讨论】:
我有一个带有多个TextEdits 的活动,并且在纵向模式下,一切都完美显示。但是当我将设备切换到横向模式时,几个视图没有显示(它们被剪切)。我可以以某种方式自动添加当设备切换到横向模式时滚动到视图?
【问题讨论】:
检查您的设备何时处于纵向模式并添加:
ScrollView scroll = new ScrollView(yourContext);
scroll.setBackgroundColor(android.R.color.transparent);
scroll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
scroll.addView(yourView);
【讨论】:
您可以尝试这样做,这可能对您有帮助:
将 ScrollView 添加到您的布局并设置此标志 android:fillViewport="true"
例如:
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
// your layout
</LinearLayout>
</ScrollView>
当您的屏幕上没有足够的空间放置项目时,将启用滚动。然后你可以滚动屏幕。 因此,如果将屏幕方向更改为横向,您可以滚动项目,而纵向则可以完美显示所有内容,而无法滚动。
【讨论】: