use*_*081 3 android scrollview imageview android-activity
我一直在尝试让大图像(10345x1280 像素)适合我的 android 屏幕(横向模式)基本上我希望 1280px 尺寸适合屏幕的高度,我希望较长的尺寸可以从左侧滚动到右边。
我一直在使用各种方法,但由于滚动不起作用或图像没有正确缩放,我真的没有太多运气。现在我正在尝试在滚动视图中使用图像视图,主要问题是在滚动视图中嵌入图像视图会弄乱图像的缩放比例。附加的照片显示了将 imageview 嵌入滚动视图之前和之后的比较。
第一张图片是我试图通过滚动实现的理想效果,所以如果有人知道最好的方法是什么,我真的很感激。
谢谢
http://i.imgur.com/OWkPNqp.png http://i.imgur.com/YGIdEY1.png
编辑:我对 xml 代码做了一些调整,我还调整了我的图像的高度为 400(所以它现在是 3233x400)。图片现在更适合屏幕,但仍然不完美,它向上/向下滚动但不是我需要的左右滚动......在所有设备类型上?
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#0099cc"
tools:context=".FullscreenActivity"
android:nestedScrollingEnabled="true">
<!-- The primary full-screen view. This can be replaced with whatever view
is needed to present your content, e.g. VideoView, SurfaceView,
TextureView, etc. -->
<TextView android:id="@+id/fullscreen_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
android:textColor="#33b5e5"
android:textStyle="bold"
android:textSize="50sp"
android:gravity="center"
android:text="@string/dummy_content" />
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="0dp" >
<LinearLayout
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:layout_marginTop="0dp"
tools:context=".HelpActivity"
android:layout_gravity="center">
<ImageView
android:id="@+id/imageHelp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:layout_marginTop="0dp"
android:src="@drawable/fretz" />
</LinearLayout>
</ScrollView>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
您的布局中有很多问题,首先是 ScrollView 中的嵌套布局LinearLayout,它只包含不必要的 ImageView,ScrollView还会自动滚动图像的垂直轴而不是其水平轴,请考虑使用HorizontalScrollView适合您的需求。
我重新制作您的布局,使用水平HorizontalScrollView滚动它,效果很好:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#0099cc"
tools:context=".FullscreenActivity" >
<TextView
android:id="@+id/fullscreen_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:keepScreenOn="true"
android:text="SAMPLE"
android:textColor="#33b5e5"
android:textSize="50sp"
android:textStyle="bold" />
<HorizontalScrollView
android:layout_width="500dp"
android:layout_height="fill_parent"
android:layout_marginTop="0dp" >
<ImageView
android:id="@+id/imageHelp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/lal" />
</HorizontalScrollView>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8379 次 |
| 最近记录: |