圆形圆形菜单在android中

时间:2014-03-04 06:40:49

标签: android android-linearlayout

我正在尝试创建一个这样的圆形菜单:

like this

我正在使用 ArcMenu图书馆。 我的xml代码是

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:arc="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <com.capricorn.ArcMenu
        android:id="@+id/arc_menu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
       />
</LinearLayout>

MainActivity.java

public class MainActivity extends Activity {
private static final int[] ITEM_DRAWABLES = { R.drawable.composer_camera, R.drawable.composer_music,
        R.drawable.composer_place, R.drawable.composer_sleep, R.drawable.composer_thought, R.drawable.composer_with };

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ArcMenu menu = (ArcMenu) findViewById(R.id.arc_menu);

    ArcLayout arcLayout= new ArcLayout(this);
    arcLayout.setChildSize(50);
    arcLayout.setArc(0.0f, 300.0f); 



    final int itemCount = ITEM_DRAWABLES.length;
    for (int i = 0; i < itemCount; i++) {
        ImageView item = new ImageView(this);
        item.setImageResource(ITEM_DRAWABLES[i]);

        final int position = i;
        menu.addItem(item, new OnClickListener() {

            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "position:" + position, Toast.LENGTH_SHORT).show();
            }
        });// Add a menu item
    }
}


}

并且输出不是全面的。

以这种方式输出:

enter image description here

请建议我如何设置圆形菜单 我是新的android所以请帮帮我

1 个答案:

答案 0 :(得分:4)

尝试

 arcLayout.setArc(0.0f, 360.0f); 

<强>编辑:

以下代码没有使用:

    ArcLayout arcLayout= new ArcLayout(this);
    arcLayout.setChildSize(50);
    arcLayout.setArc(0.0f, 300.0f); 

您只需更改下面的布局代码,然后检查

   <com.capricorn.ArcMenu
        android:id="@+id/arc_menu_2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        arc:fromDegrees="0.0"
        arc:toDegrees="360.0"
        arc:childSize="50dp"/>