하나의보기에 2 개의 다른 이미지가 있어야합니다. GraphicsView (이)는 애니메이션 (실제로 이미지 뷰의 중심에 그것을 자기 회전)과 R.layout.main 가정된다 뷰의 배경 (있어야하는데 뷰의 상단)에 다시 정적 이미지는안드로이드에 2 개의 서로 다른보기 setContentView
내가 필요한 것은 뷰의 상단에 이미지 뷰이며 내가 가지고있는 애니메이션보기 노호
public class spinball extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(new GraphicsView(this));
setContentView(R.layout.main);
}
private static class GraphicsView extends View {
private Bitmap ball;
private int XOffset;
private int YOffset;
private Animation anim;
public GraphicsView(Context context) {
super(context);
ball = BitmapFactory
.decodeResource(getResources(), R.drawable.ball);
XOffset = ball.getWidth()/2;
YOffset = ball.getHeight()/2;
}
private void createAnim(Canvas canvas) {
anim = new RotateAnimation(0, 360, canvas.getWidth()/2, canvas
.getHeight()/2);
anim.setRepeatMode(Animation.RESTART);
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(10000L);
anim.setInterpolator(new AccelerateDecelerateInterpolator());
startAnimation(anim);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// creates the animation the first time
if (anim == null) {
createAnim(canvas);
}
Path circle = new Path();
int centerX = canvas.getWidth()/2;
int centerY = canvas.getHeight()/2;
int r = Math.min(centerX, centerY);
circle.addCircle(centerX, centerY, r, Direction.CW);
Paint paint = new Paint();
canvas.drawBitmap(ball, centerX - jobsXOffset,
centerY - jobsYOffset, null);
}
}
}
main.xml에
<?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="wrap_content"
>
<ImageView android:src="@drawable/static_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
/>
</LinearLayout>
질문을 명확하게하십시오. 약삭 바삭한 자세. – Praveen
전체 코드를 포함 시켰습니다. 더 자세히 설명 드리겠습니다. – thpoul