2012-10-18 3 views
2

이것은 가장 간단한 것이어야합니다. ViewPropertyAnimator를 사용하여 이미지 뷰를 중심 주위로 축척하려고합니다.안드로이드 스케일 중심의 이미지 뷰

<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" > 

<ImageView 
    android:id="@+id/imageView" 
    android:background="@android:color/black" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true"/> 

<ImageView 
    android:id="@+id/target" 
    android:layout_centerInParent="true" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/crosshair" 
    /> 
그런

나는 다음과 같은 코드가있다 : 나는이 코드를 실행하면

// Now we show the burst view 
       if(mLastBurst != null) 
       { 
        ((FrameLayout)(mLastBurst.getParent())).removeView(mLastBurst); 
        mLastBurst.animate().cancel(); 
        mLastBurst.setVisibility(View.GONE); 
       } 

       mLastBurst = getLayoutInflater().inflate(R.layout.target, null); 
       mLastBurst.setX(event.getX()-mLastBurst.getWidth()/2); 
       mLastBurst.setY(event.getY()-mLastBurst.getHeight()/2); 
       mLastBurst.setPivotX(50); 
       mLastBurst.setPivotY(50); 
       mLastBurst.animate().scaleXBy(10).scaleYBy(10).setDuration(500); 
       addContentView(mLastBurst,new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); 

일어나는 모든 즉보다는 확장

나는 다음과 같은 레이아웃을 가지고 이미지 중심 근처의 이미지, 이미지가 왼쪽으로 이동합니다.

나는 pivotX 및 pivotY 값을 사용하여 아무런 효과가 없습니다. 이것은 간단해야하고 나는 명백한 무엇인가 놓치고 있다고 생각한다.

답변

0

pivotX 및 pivotY를 설정하지 않으려하면 기본적으로 가운데에 배치됩니다. 당신이 그들을 설정하면 단위가 픽셀이라고 생각합니다.

+0

나는 이미 그것도 시도했다. 기쁨이 없습니다. – Lee

+0

너비와 높이를 물을 때 치수가 알려 집니까? 콘텐츠보기는 다른보기와 다르게 처리됩니다. 다른 용기를 사용해보십시오. –

관련 문제