Android- scrollview中的线性延迟
-
26-10-2019 - |
题
由于我的UI很简单,因此我想在一个XML文件中迎合风景和肖像。
在肖像模式下,一切都是我想要的。
在景观中,几乎没有显示main_title TextView。为此有工作吗?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:background="@color/background"
android:layout_width="fill_parent" android:padding="20dip"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:layout_height="fill_parent"
android:layout_gravity="center" android:orientation="vertical"
android:layout_marginTop="30dip" android:id="@+id/LinearLayout01"
android:layout_width="fill_parent">
<TextView android:layout_marginBottom="15dip"
android:textSize="24.5sp" android:layout_height="wrap_content"
android:id="@+id/TextView01" android:layout_gravity="center"
android:text="@string/main_title" android:layout_width="wrap_content"></TextView>
<Button android:layout_marginBottom="15dip"
android:layout_height="wrap_content" android:id="@+id/start_button"
android:text="@string/start_label" android:layout_width="fill_parent"></Button>
<TextView android:textSize="18sp" android:layout_height="wrap_content"
android:id="@+id/TextView02" android:text="@string/time_window_please_select_label"
android:layout_width="wrap_content"></TextView>
<Spinner android:layout_height="wrap_content" android:id="@+id/spinner"
android:prompt="@string/time_window_prompt" android:layout_width="fill_parent"></Spinner>
<TextView android:layout_height="wrap_content"
android:layout_marginBottom="10dip" android:id="@+id/status_label"
android:layout_width="wrap_content"></TextView>
<TextView android:layout_height="wrap_content"
android:layout_marginBottom="10dip" android:id="@+id/status_time_label"
android:layout_width="wrap_content">
</TextView>
<ImageView android:layout_marginTop="60dip" android:id="@+id/info_button"
android:src="@drawable/info" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="bottom|right" />
</LinearLayout>
</ScrollView>
链接:
解决方案
看起来问题在于您 margin
和 padding
值。
最好的选择可能是为此有2种不同的布局,其中1个是肖像,其他是景观。创建另一个名称的文件夹 layout-land
和 layout-port
在你的 res
文件夹。然后将布局文件复制到两个文件夹中,并为方向进行适当的更改。
有关为不同方向提供不同资源的更多信息,请参见Android文档: http://developer.android.com/guide/topics/resources/providing-resources.html#alternativeresources
其他提示
在文件顶部添加一个空白的文本视图,即在文本视图上方不可见。也许您的内容区域很大,屏幕无法支持它。您面临的问题首先不应该发生。...但这是一项工作。也尝试切换仿真器...
不隶属于 StackOverflow