Android平台:如何显示可滚动、可缩放的图像



我有一组8张图片,我想依次显示它们。点击按钮后将显示下一张图片。

我可以在imageview中加载我的图像。1. 我找不到如何改变按钮点击图像2. 如何在程序中进行更改,使图像可剪切&缩放的。

enter code here
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:layout_weight="1">
  <ImageView
  android:id="@+id/imageview1"
  android:gravity="center_horizontal"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:layout_weight="1"
  android:src="@drawable/img1"      
  android:adjustViewBounds="true"
  android:keepScreenOn="true" 
  android:scrollbarStyle="outsideOverlay"
  android:scrollbars="horizontal" android:scaleType="fitXY"/>
  <Button      
  android:layout_height="wrap_content"
  android:layout_width="fill_parent"
  android:id="@+id/button1"
  android:text="Next"/>
</LinearLayout>
  1. 在按钮调用的onClickLister中:
    YourImageView.setImageBitmap(YourBitmap);

  2. 查看此链接。这是一个关于Android多点触控手势基础知识的很棒的教程,它还提供了如何移动和缩放图像的示例。

关于缩放ImageView,请参阅这篇文章。至于如何在单击按钮时更改图像,我建议您从这里阅读如何添加按钮单击侦听器。谷歌"android button onclick example",你会发现很多例子。如果你仍然不确定如何在点击按钮时更改图像,你应该查看Android开发者指南,它有很多有用的信息,如处理事件,UI等…

这里也有一些很棒的教程

最新更新