`

android > 图片旋转

 
阅读更多

T3Activity.java

package t3.com;


import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.widget.ImageView;


public class T3Activity extends Activity {
    /** Called when the activity is first created. */

	private ImageView iv;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        iv = (ImageView)findViewById(R.id.iv);
        
        Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(), 
                R.drawable.t);
        int width = bitmapOrg.getWidth(); 
        int height = bitmapOrg.getHeight(); 
        
        // 创建操作图片用的matrix对象
        Matrix matrix =  new Matrix();
        matrix.postRotate(270);	//旋转度数 
        
        Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0, 
                width, height, matrix, true); 
        BitmapDrawable bmd = new BitmapDrawable(resizedBitmap); 
        iv.setImageDrawable(bmd);
        
    }  
	//\\
}

 

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
	<RelativeLayout 
	    android:layout_width="fill_parent"
	    android:layout_height="wrap_content"
	    >
		 <ImageView 
		     android:id="@+id/iv"
	        android:layout_width="wrap_content"
	        android:layout_centerInParent="true"
	        android:layout_height="wrap_content"
	        android:background="@android:color/transparent"
	    
	        />
	</RelativeLayout>


</LinearLayout>
 
分享到:
评论

相关推荐

    android 3D立体图片旋转

    在Android平台上,3D立体图片旋转是一种常见的视觉效果,它能为用户带来更生动、更具沉浸感的体验。本文将深入探讨如何实现这一技术,并基于提供的代码项目进行讲解。 首先,我们要了解Android中的3D渲染基础。...

    Android开发之图片旋转功能实现方法【基于Matrix】

    本文实例讲述了Android开发之图片旋转功能实现方法。分享给大家供大家参考,具体如下: 在Android中进行图像旋转需要使用Matrix,它包含了一个3*3的矩阵,专门用于进行图像变换匹配。Matrix ,中文里叫矩阵,高等...

    android图片旋转、控件旋转

    andriod旋转动画,支持view、图片旋转,调用方式已写好,包含旋转监听,非常方便的一款实用型andriod图片旋转动画

    android-opengl图片3d旋转

    本文将深入探讨如何使用OpenGL ES在Android上实现图片的3D旋转。 首先,理解OpenGL ES的基本概念至关重要。OpenGL ES是OpenGL的一个子集,专为嵌入式系统设计,如智能手机和平板电脑。它提供了一个离散的图形编程...

    android3D旋转图片

    在Android开发中,3D旋转图片是一种常见的动画效果,可以为用户界面增添动态感和立体感。本实例主要探讨如何实现这一功能。Android 3D旋转通常涉及到Android的图形渲染和矩阵运算,其中Matrix类是核心工具。接下来,...

    Android图片左右旋转

    首先,我们要明白图片旋转的基本原理。在二维空间中,图片的旋转可以通过矩阵变换来实现。在Android中,我们可以利用Matrix类提供的方法来对图片进行旋转操作。Matrix类提供了postRotate()和preRotate()两个方法,...

    Android开发图片旋转的两种方式

    本教程将详细讲解两种实现Android图片旋转的方法:动画(Animation)和Matrix变换。 一、动画(Animation)方式 1. 创建旋转动画资源文件:在res/anim目录下创建rotate.xml,内容如下: ```xml &lt;rotate xmlns:...

    Android开发图片旋转和视频播放

    一、Android图片旋转 1. **获取图片原始角度**:图片在拍摄时可能带有旋转信息,这通常存储在Exif(Exchangeable image file format)元数据中。通过`ExifInterface`类可以读取图片的Exif信息,找出旋转角度。 2. ...

    如何在Android中实现图片及动画的缩放和旋转

    " Android 图片及动画的缩放和旋转实现" Android 动画有两种:Tween Animation 和 Frame Animation。本文主要介绍 Tween Animation 的实现, Tween Animation 是对视图对象中的内容进行一系列简单的转换,比如位置...

    android 图片旋转

    在Android开发中,图片旋转是一项常见的操作,可以用于实现用户交互或者界面动态效果。本文将深入探讨如何使用`Matrix`和`RotateAnimation`来旋转图片,并允许用户输入自定义的角度。 首先,`Matrix`是Android图形...

    android图片处理:让图片一直匀速旋转

    对于图片旋转,我们可以使用`ObjectAnimator`,它是属性动画的一种,可以直接作用于对象的属性。我们需要设置`ObjectAnimator`的目标属性为`rotation`,这代表图片的旋转角度。 2. **创建无限旋转动画**: 要实现...

    Android实训-图片编辑工具(裁剪+旋转)

    在Android中,图片旋转通常通过`Matrix`类实现,它可以对图像进行各种几何变换。以下是图片旋转的基本步骤: 1. **获取Matrix对象**:创建一个新的`Matrix`实例,用于存储旋转操作。 2. **设定旋转中心**:确定旋转...

    android图片旋转、淡入淡出、缩放、移动效果

    以上代码演示了Android中实现图片旋转、淡入淡出、缩放和移动的基本方法。实际应用时,还可以结合使用这些动画,创建更复杂的组合动画,例如同时执行多个动画,或者设置动画监听器以在动画开始、结束或更新时执行...

    Android代码-旋转图片的PhotoView

    RotatePhotoView Adding Rotation with two finger function on PhotoView Set Up Gradle ...and don't forget to add jcenter() to repositories Usage in code you need to enable rotation, by default it's false....

    Android-CarouselEffectViewPager的旋转木马效果

    "Android-CarouselEffectViewPager"是一个专门为Android平台设计的库,它允许开发者实现类似旋转木马的滑动浏览效果,通常用于展示图片、广告轮播或内容卡片。这个库基于Android的`ViewPager`组件,通过自定义适配器...

    Android 3d 图片 旋转动画

    在Android开发中,3D图片旋转动画是一种常见且吸引用户注意力的视觉效果。它能够为应用程序增添生动性和交互性。本文将深入探讨如何在Android中实现3D图片旋转动画,包括基本概念、所需技术以及具体步骤。 首先,...

    android图片的旋转(一分钟学会)

    综上所述,Android图片旋转主要依赖于Bitmap和Matrix的结合使用,通过设置旋转角度和应用变换矩阵来完成。理解这一机制对于开发中处理图片的显示和编辑至关重要。在实际项目中,结合Exif信息处理和优化内存使用,能...

    Android studio 实现图片翻转

    1. **视图动画**:在Android中,视图动画主要通过`Animation`类家族来实现,如`TranslateAnimation`(平移)、`RotateAnimation`(旋转)、`ScaleAnimation`(缩放)和`AlphaAnimation`(透明度变化)。图片翻转可以...

    android 图片旋转 叠加 去黑边

    利用Canvas 的save,translate,rotate 相关方法,可以比较快速的实现图片旋转,且中心点不偏移。避免了使用Bitmap中setRotate中旋转覆盖且出现黑边的问题。可以直接下载使用自定义控件就可以了。

    Android 仿百度播放器圆形图片旋转效果.rar

    这个压缩包"Android 仿百度播放器圆形图片旋转效果.rar"提供了一个实例,教你如何在Android应用中创建一个类似百度网页音乐播放器的圆形图片旋转动画效果。这个效果通常用于表示加载或播放状态,给用户一种动态反馈...

Global site tag (gtag.js) - Google Analytics