【发布时间】:2015-08-12 14:59:39
【问题描述】:
我有一个包含文本的图像,在大屏幕设备上显示良好,但在小屏幕设备上无法读取文本。我决定使用一种尺寸并在较小的屏幕上滚动。我使用下面的代码来设置垂直滚动和水平滚动,但它只会垂直滚动。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical">
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="820px"
android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".CategoriesActivity">
.
.
.
<ImageView
android:id="@+id/termsImg"
android:layout_width="450dp"
android:layout_height="600dp"
android:layout_below="@+id/headerPanel"
android:background="@drawable/screen1" />
</HorizontalScrollView>
</ScrollView>
水平滚动适用于较大的屏幕,但不适用于 240 或 320 尺寸的屏幕。
我需要进行哪些更改才能让我的 imageView 水平和垂直滚动?
【问题讨论】:
-
首先你不需要在每个 Xml 标签中声明 xmlns:android 它应该只出现在 ScrollView 标签中,即第一个父级应该包含这一行
标签: android android-layout android-scrollview horizontalscrollview