[英]How can I get my imageView to scroll horizontally as well as vertically?
我有一个包含文本的图像,并且在较大的屏幕设备上可以正常显示,但是在较小的屏幕上无法读取文本。 我决定使用一种尺寸并在较小的屏幕上滚动。 我使用下面的代码设置了垂直滚动和水平滚动,但是只能垂直滚动。
<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水平和垂直滚动?
就是这样
<ScrollView
android:id="@+id/layout0"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/layout1"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<HorizontalScrollView
android:id="@+id/layout2"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/layout3"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
<!-- Your ImageVIew -->
</ImageVIew>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
</ScrollView>
但是如您所见,它似乎效率很低。 您可以通过将图像视图缩放到适当的scaleType
并使用一个ScrollView
来解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.