2

나는 XML을 가지고 있습니다. 어느 것이 상대적 레이아웃을 가지고 있습니다. 그리고 그 레이아웃에는 몇 가지 TextField가 있습니다. 상대적인 레이아웃의 중간에는 ImageView가 있습니다. 전체 이미지를 확대 할 수 있도록 imageView 확대/축소하려고합니다. 이제 ImageView 내부 만 확대 할 수 있습니다. ImageView와 마찬가지로 화면이 나타나고 확대/축소는 내부에서만 발생합니다. 하지만 전체 화면을 기준으로 확대/축소하려고합니다. 이미지가 확대 될 때 TextField가 그 위치를 유지하기를 원하지만 이미지가 확대 될 때 TextField가 덮여 야합니다. 그것을 할 방법이 있습니까? 감사.이미지 뷰를 전체 화면으로 확대

+0

는'imageview'를위한'xml' 코드를 보여줍니다 –

답변

1

는 고해상도에 ANIM 폴더에 zoom_in.xml를 만들고 코드를

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" 
android:fillAfter="true" > 

<scale 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:duration="1000" 
    android:fromXScale="1" 
    android:fromYScale="1" 
    android:pivotX="50%" 
    android:pivotY="50%" 
    android:toXScale="3" 
    android:toYScale="3" > 
</scale> 

에 따라 작성하고 코드에 다음 코드

public class ZoomInActivity extends Activity implements AnimationListener { 

ImageView imgPoster; 
Button btnStart; 

// Animation 
Animation animZoomIn; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_zoom_in); 

    imgPoster = (ImageView) findViewById(R.id.imgLogo); 
    btnStart = (Button) findViewById(R.id.btnStart); 

    // load the animation 
    animZoomIn = AnimationUtils.loadAnimation(getApplicationContext(), 
      R.anim.zoom_in); 

    // set animation listener 
    animZoomIn.setAnimationListener(this); 

    // button click event 
    btnStart.setOnClickListener(new View.OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      // start the animation 
      imgPoster.startAnimation(animZoomIn); 
     } 
    }); 

} 

@Override 
public void onAnimationEnd(Animation animation) { 
    // Take any action after completing the animation 

    // check for zoom in animation 
    if (animation == animZoomIn) {   
    } 

} 

@Override 
public void onAnimationRepeat(Animation animation) { 
    // TODO Auto-generated method stub 

} 

@Override 
public void onAnimationStart(Animation animation) { 
    // TODO Auto-generated method stub 

} 

} 

를 작성하여 activity_zoom_in.xml입니다

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#000000" 
android:gravity="center"> 

<ImageView android:id="@+id/imgLogo" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/man_of_steel" 
    android:layout_centerInParent="true"/> 

<Button android:id="@+id/btnStart" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Start Animation" 
    android:layout_marginTop="30dp" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="20dp"/> 

</RelativeLayout> 
관련 문제