CircularMenu - 可高度自定义的环形菜单Android控件

JackieBurns 9年前

可高度自定义的环形菜单Android控件,能够自定义中心view,通过adapter控制itemview,menu数量,中心圆大小,中心圆环大小。

运行效果:

使用说明:

MainActivity

package sunger.net.org;    import android.os.Bundle;  import android.support.v7.app.AppCompatActivity;  import android.view.View;  import android.widget.Button;  import android.widget.EditText;    import org.sunger.net.view.CircularMenu;    import sunger.net.org.a.R;    public class MainActivity extends AppCompatActivity {      private CircularMenu wheelMenuView;      private EditText editText1, editText2, editText3, editText4, editText5, editText6;      private Button button;      private PanAdapter adapter;        @Override      protected void onCreate(Bundle savedInstanceState) {          super.onCreate(savedInstanceState);          setContentView(R.layout.activity_main);          wheelMenuView = (CircularMenu) findViewById(R.id.panview);          //  wheelMenuView = new WheelMenuView(this);  //        setContentView(wheelMenuView);  //        wheelMenuView.setLineWidth(20);  //        wheelMenuView.setItemCount(6);  //        wheelMenuView.setBackgroundColor(Color.BLACK);  //        wheelMenuView.setPressedColor(Color.BLUE);  //        wheelMenuView.setRadius(300);  //        wheelMenuView.setInnerRadius(120);  //        wheelMenuView.setItemColor(Color.CYAN);  //        wheelMenuView.setCenterView(R.layout.center_layout);  //        wheelMenuView.setRadiusLineWidth(20);  //        wheelMenuView.setStartAngle(5);          adapter = new PanAdapter();          wheelMenuView.setAdapter(adapter);          editText1 = (EditText) findViewById(R.id.editText1);          editText2 = (EditText) findViewById(R.id.editText2);          editText3 = (EditText) findViewById(R.id.editText3);          editText4 = (EditText) findViewById(R.id.editText4);          editText5 = (EditText) findViewById(R.id.editText5);          editText6 = (EditText) findViewById(R.id.editText6);          button = (Button) findViewById(R.id.button);          button.setOnClickListener(new View.OnClickListener() {              @Override              public void onClick(View v) {                  //大圆半径                  float radius = Float.valueOf(editText1.getText().toString());                  float innerRadius = Float.valueOf(editText2.getText().toString());                  //线条宽度                  float lineWidth = Float.valueOf(editText3.getText().toString());                  //内圆线宽度                  float radiusLineWidth = Float.valueOf(editText4.getText().toString());                  int itemCount = Integer.valueOf(editText5.getText().toString());                  int startAngle = Integer.valueOf(editText6.getText().toString());                  wheelMenuView.setInnerRadius(innerRadius);                  wheelMenuView.setLineWidth(lineWidth);                  wheelMenuView.setItemCount(itemCount);                  wheelMenuView.setStartAngle(startAngle);                  wheelMenuView.setRadiusLineWidth(radiusLineWidth);                  wheelMenuView.setRadius(radius);              }          });        }  }

PanAdapter

package sunger.net.org;    import android.view.LayoutInflater;  import android.view.View;  import android.view.ViewGroup;  import android.widget.BaseAdapter;  import android.widget.TextView;    import sunger.net.org.a.R;    /**   * Created by sunger on 16/1/26.   */  public class PanAdapter extends BaseAdapter {      @Override      public int getCount() {          return 6;      }        @Override      public Object getItem(int position) {          return null;      }        @Override      public long getItemId(int position) {          return 0;      }        @Override      public View getView(int position, View convertView, ViewGroup parent) {          TextView textView = (TextView) LayoutInflater.from(parent.getContext()).inflate(R.layout.item_view, null,false);          textView.setText("Item" + position);          return textView;      }  }


</div>

项目地址: https://github.com/sungerk/CircularMenu