2014-04-16 4 views
-1

이미지를 90도 기울어 진 직사각형으로 표시하고 싶습니다. 내가 어떻게 할 수 있니? 내가 이미지를이미지를 사각형으로 표시 하시겠습니까?

나에게주세요 몇 가지 솔루션을 표시하려면이 프레임에서

enter image description here

.

감사합니다.

+3

사각형이 보입니다. 45 °로 기울어졌습니다 ... –

+0

http://stackoverflow.com/questions/21002224/add-a-background-image-to-shape-in-xml-android – weston

+1

@BobMalooga 사각형은 사각형의 서브 클래스입니다. –

답변

0

아래의 방법을 사용하십시오. API와

public static Bitmap rotate(Bitmap src, float degree) { 
    // create new matrix 
    Matrix matrix = new Matrix(); 
    // setup rotation degree 
    matrix.postRotate(degree); 

    // return new bitmap rotated using matrix 
    return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true); 
} 
1

> = 11

mImageView.setRotation(angle) 

또 다른 방법 :

ImageView img = (ImageView)findViewById(R.id.yourImageViewId); 
Options o = getSize(this, R.drawable.yourImage); 
Matrix m = new Matrix(); 
m.postRotate(angle, o.outWidth/2, o.outHeight/2); 
img.setScaleType(ScaleType.MATRIX); 
img.setImageMatrix(m); 
+0

+1 –

3

당신은 45D 애니메이션을 만들고 다음과 같이 귀하의 이미지 뷰에 적용 할 수 :

ImageView image= (ImageView)findViewById(R.id.imageView); 
    // Create 45d animaion 
    Animation an = new RotateAnimation(0.0f, 45f, image.getPivotX(), image.getPivotY()); 

    // Set the animation's parameters 
    an.setDuration(1);    
    an.setRepeatCount(0);     
    an.setRepeatMode(Animation.REVERSE); 
    an.setFillAfter(true);    

    // Aplly animation to image 
    image.setAnimation(an); 
0

모든 API 용 장소 레이아웃 XML의 ImageView를 선택하고 해당 활동의 onCreate()에 애니메이션을 설정하면 다음과 같습니다.

float rotationDegree = -45; //You can change if you need. 
     Animation anim = new RotateAnimation(0,rotationDegree); 
     anim.setFillAfter(true); 
     imageView.startAnimation(anim); 
관련 문제