我想实现一个放射状菜单小部件,我使用了radial-menu-v4 jar。我的代码如下......
public class RadialMenuActivity extends Activity {
private RadialMenuWidget pieMenu;
public Activity activity = this;
RelativeLayout l1;
public RadialMenuItem menuItem1,menuItem2,menuItem3,menuItem4,menuItem5,menuItem6,menuItem7,menuItem8,menuItem9,menuItem10, menuCloseItem, menuExpandItem;
public RadialMenuItem firstChildItem, secondChildItem, thirdChildItem;
private List<RadialMenuItem> children = new ArrayList<RadialMenuItem>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.radial);
pieMenu = new RadialMenuWidget(this);
l1 = (RelativeLayout)findViewById(R.id.reltv1);
l1.addView(pieMenu);
menuCloseItem = new RadialMenuItem("Close", "Menu");
//menuCloseItem.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem1 = new RadialMenuItem("1","j");
menuItem1.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
/*firstChildItem = new RadialMenuItem("First","First");
firstChildItem.setOnMenuItemPressed(new RadialMenuItem.RadialMenuItemClickListener() {
@Override
public void execute() {
startActivity(new Intent(RadialMenuActivity.this, TestActivity.class));
pieMenu.dismiss();
}
});
secondChildItem = new RadialMenuItem("Second",null);
secondChildItem.setDisplayIcon(R.drawable.ic_launcher);
secondChildItem.setOnMenuItemPressed(new RadialMenuItem.RadialMenuItemClickListener() {
@Override
public void execute() {
Toast.makeText(RadialMenuActivity.this, "Second inner menu selected.", Toast.LENGTH_LONG).show();
}
});
thirdChildItem = new RadialMenuItem("Third","Third");
thirdChildItem.setDisplayIcon(R.drawable.ic_launcher);
thirdChildItem.setOnMenuItemPressed(new RadialMenuItem.RadialMenuItemClickListener() {
@Override
public void execute() {
Toast.makeText(RadialMenuActivity.this, "Third inner menu selected.", Toast.LENGTH_LONG).show();
}
});*/
menuItem2 = new RadialMenuItem("2", "a");
menuItem2.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem3 = new RadialMenuItem("3", "i");
menuItem3.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem4 = new RadialMenuItem("4", "b");
menuItem4.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem5 = new RadialMenuItem("5", "c");
menuItem5.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem6 = new RadialMenuItem("6", "d");
menuItem6.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem7 = new RadialMenuItem("7", "e");
menuItem7.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem8 = new RadialMenuItem("8", "f");
menuItem8.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem9 = new RadialMenuItem("9", "g");
menuItem9.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem10 = new RadialMenuItem("10", "h");
menuItem10.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
/*children.add(firstChildItem);
children.add(secondChildItem);
children.add(thirdChildItem);*/
//menuExpandItem.setMenuChildren(children);
menuCloseItem.setOnMenuItemPressed(new RadialMenuItem.RadialMenuItemClickListener() {
@Override
public void execute() {
//menuLayout.removeAllViews();
pieMenu.dismiss();
}
});
menuItem1.setOnMenuItemPressed(new RadialMenuItem.RadialMenuItemClickListener() {
@Override
public void execute() {
startActivity(new Intent(RadialMenuActivity.this, TestActivity.class));
pieMenu.dismiss();
}
});
//pieMenu.setDismissOnOutsideClick(true, menuLayout);
int xLayoutSize = l1.getWidth();
int yLayoutSize = l1.getHeight();
pieMenu.setAnimationSpeed(0L);
//pieMenu.setSourceLocation(200, 200);
pieMenu.setSourceLocation(1000,1000);
pieMenu.setIconSize(10, 20);
pieMenu.setTextSize(10);
pieMenu.setOutlineColor(Color.WHITE, 225);
//pieMenu.setInnerRingColor(0xAA66CC, 10000000);
//pieMenu.setOuterRingColor(0x0099CC, 10000000);
//pieMenu.setCenterCircleRadius(40);
pieMenu.setOuterRingRadius(600, 600);
//pieMenu.setInnerRingRadius(100,100);
//pieMenu.setHeader("Test Menu", 20);
pieMenu.setCenterCircle(menuCloseItem);
pieMenu.addMenuEntry(new ArrayList<RadialMenuItem>() {{
add(menuItem1);
add(menuItem2);
add(menuItem3);
add(menuItem4);
add(menuItem5);
add(menuItem6);
add(menuItem7);
add(menuItem8);
add(menuItem9);
add(menuItem10);
}});
//pieMenu.addMenuEntry(menuItem);
//pieMenu.addMenuEntry(menuExpandItem);
/*Button testButton = (Button) this.findViewById(R.id.radial_menu_btn);
testButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//menuLayout.addView(pieMenu);
pieMenu.show(v);
}
});*/
}
但是我不能增加圆的外半径。我正在使用min sdk版本8.请帮助我。提前谢谢。