弧形动画菜单

             最近公司项目需求,需要做一个弧形动画菜单的效果,在网上找了很久终于找到了自己想要的效果,现在记录下来以方便自己和大家学习,效果图如下:




             首先需要添加依赖:

            

compile 'csy.menu.satellitemenulib:SatelliteMenu:1.0.3'

            在布局中的使用如下:

           

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.a31210.myeventbus.MenuActivity">
    <TextView
        android:id="@+id/tvTitle"
        android:layout_width="match_parent"
        android:layout_height="45dp"
        android:textColor="#ffffff"
        android:textSize="18sp"
        android:gravity="center"
        android:text="弧形动画菜单"
        android:background="@color/colorPrimary"/>

    <csy.menu.satellitemenulib.view.SatelliteMenu
        android:id="@+id/mStatelliteMenuLeftTop"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="45dp"
        app:menu_postion="left_top"
        app:radius="150dp"
        app:menu_image_width="45dp"
        app:menu_item_image_width="50dp"
        app:menu_item_text_size="4sp"
        app:menu_item_text_color="@color/colorPrimary">

    </csy.menu.satellitemenulib.view.SatelliteMenu>

</RelativeLayout>

        代码中的使用如下:

public class MenuActivity extends AppCompatActivity {
    private SatelliteMenu mStatelliteMenuLeftTop;
    private List<Integer>imgList=new ArrayList<>();
    private List<String>textList=new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_menu);
        imgList.add(R.mipmap.ic_launcher_round);
        imgList.add(R.mipmap.ic_launcher_round);
        imgList.add(R.mipmap.ic_launcher_round);
        imgList.add(R.mipmap.ic_launcher_round);
        textList.add("音乐");
        textList.add("电视");
        textList.add("电影");
        textList.add("新闻");
        mStatelliteMenuLeftTop= (SatelliteMenu) findViewById(R.id.mStatelliteMenuLeftTop);
        mStatelliteMenuLeftTop.getmBuilder()
                .setMenuImage(R.mipmap.ic_launcher_round)
                .setMenuItemImageResource(imgList)
                .setMenuItemNameTexts(textList)
                .setOnMenuItemClickListener(new SatelliteMenu.OnMenuItemClickListener() {
                    @Override
                    public void onClick(View view, int postion) {
                        Toast.makeText(MenuActivity.this,"点击了菜单"+postion,Toast.LENGTH_LONG).show();

                    }
                }).creat();
    }
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值