2014-03-04 48 views
3

我想創建一個圓圈菜單是這樣的:圓角圓菜單在安卓

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新功能所以,請幫我

+0

你必須改變程度在ArcMenu – Piyush

+0

剛剛擺脫的' arcLayout.setChildSize(50);''''和'arcLayout.setArc(0.0f,300.0f);'並嘗試 –

+0

感謝兄弟,但我已經使用它不工作 – Kuldeep

回答

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"/> 
+0

感謝重播兄弟,但我想要[鏈接](https://dl.dropbox.com/u/11 369687/preview1.png) – Kuldeep

+0

這就是我所做的你必須定義程度和從0.0到360.0度以獲得圓形佈局。 – GrIsHu

+0

@ user3145614查看我更新的答案。其實你根本就沒有在你的ArcMenu中設定度數。這就是爲什麼它沒有向你顯示結果。你只是改成不在'ArcMenu'中的'ArcLayout'。僅供參考'ArcLayout'用於創建'ArcLayout'的動態內部,並創建'ArcMenu'。 – GrIsHu