效果图
单个图片的类
DJItemImageView.java
package com.ldci.djrotatemenuforandroid;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
public class DJItemImageView extends RelativeLayout implements OnClickListener{
public ImageView imageView;
public DJItemImageView(Context context) {
super(context);
//this.setBackgroundColor(Color.GREEN);
//设置该布局的属性
RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
lp1.addRule(RelativeLayout.CENTER_HORIZONTAL);
lp1.addRule(RelativeLayout.CENTER_VERTICAL);
// TODO Auto-generated constructor stub
imageView = new ImageView(context);
imageView.setRotation(180);
Bitmap bitmap = ((BitmapDrawable)getResources().getDrawable(R.drawable.ui_navi_course_in)).getBitmap();
//设置图片的属性
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(bitmap.getWidth(), bitmap.getHeight());
//RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
lp.addRule(RelativeLayout.CENTER_VERTICAL);
imageView.setLayoutParams(lp);
//imageView.setImageBitmap(bitmap);
imageView.setOnClickListener(this);
this.addView(imageView);
// lp1.width = bitmap.getWidth() * 3;
// lp1.height = bitmap.getHeight();
this.setLayoutParams(lp1);
}
public void setImageTag(int tagId) {
imageView.setId(tagId);
Log.i("image", "imageItem tag" + tagId);
}
public void djsetImageResources(int imageId) {
Bitmap bitmap = ((BitmapDrawable)getResources().getDrawable(imageId)).getBitmap();
imageView.setImageBitmap(bitmap);
}
@Override
public void onClick(View v) {
Log.i("image", "1111111111111111111111111111" + v.getId());
// TODO Auto-generated method stub
switch (v.getId()) {
case 1001:
Log.i("image", "1111111111111111111111111111");
break;
case 1002:
Log.i("image", "222222222222222222222222222222");
break;
case 1003:
Log.i("image", "33333333333333333333333333333");
break;
case 1004:
Log.i("image", "444444444444444444444444444");
break;
case 1005:
Log.i("image", "5555555555555555555555555555");
break;
case 1006:
Log.i("image", "66666666666666666666666666");
break;
case 10000:
Log.i("image", "777777777777777777777");
break;
default:
break;
}
}
}
6个图片的第一次集合类
DJRotateRelativeLayout.java
package com.ldci.djrotatemenuforandroid;
import java.util.ArrayList;
import android.R.integer;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
public class DJRotateRelativeLayout extends RelativeLayout{
private int imageIdsDefault[] = {R.drawable.ui_navi_home,R.drawable.ui_navi_feature,R.drawable.ui_navi_course,R.drawable.ui_navi_listen,R.drawable.ui_navi_play,R.drawable.ui_navi_more};
private int imageIdsIn[] = {R.drawable.ui_navi_home_in,R.drawable.ui_navi_feature_in,R.drawable.ui_navi_course_in,R.drawable.ui_navi_listen_in,R.drawable.ui_navi_play_in,R.drawable.ui_navi_more_in};
private ArrayList<DJItemImageView> djArrayList;
public DJRotateRelativeLayout(Context context) {
super(context);
// TODO Auto-generated constructor stub
//初始化一个数字
djArrayList = new ArrayList<DJItemImageView>();
this.setBackgroundColor(Color.TRANSPARENT);
RelativeLayout.LayoutParams bglp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
bglp.addRule(RelativeLayout.CENTER_HORIZONTAL);
bglp.addRule(RelativeLayout.CENTER_VERTICAL);
this.setLayoutParams(bglp);
//this.setOnTouchListener(this);
ImageView bgIma