Android快速SDK(11)圆弧菜单库PathView【傻瓜模式】

本文介绍了如何使用Android SDK中的PathView库创建圆弧菜单,包括依赖包、配置属性如动画时间、动画半径、对齐方式等,并展示了如何在布局文件中应用样式以及监听点击事件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

代码:http://download.youkuaiyun.com/detail/huangbin95487710/9259699

依赖包模式

完整运行还需要用到以下依赖包

  1. 支持样式属性配置
    • 支持配置动画时间
    • 支持配置动画半径
    • 支持配置对齐方式
    • 菜单按钮配置化(免代码)
    •     <declare-styleable name="Path">
      
              <!-- 展示序列 -->
              <attr name="path_menu" format="integer" />
              <!-- 主按钮 -->
              <attr name="path_icon" format="integer" />
              <!-- 主按钮动画 -->
              <attr name="path_icon_anim" format="boolean" />
              <!-- 动画时间 -->
              <attr name="path_anim" format="integer" />
              <!-- 动画半径 -->
              <attr name="path_radius" format="integer" />
              <!-- 对齐方式 -->
              <attr name="path_mode">
                  <enum name="BottomLeft" value="0" />
                  <enum name="BottomCenter" value="1" />
                  <enum name="BottomRight" value="2" />
                  <enum name="CenterLeft" value="3" />
                  <enum name="CenterRight" value="4" />
                  <enum name="TopLeft" value="5" />
                  <enum name="TopCenter" value="6" />
                  <enum name="TopRight" value="7" />
              </attr>
          </declare-styleable>

    • 默认样式
    •     <!-- 默认样式 -->
          <style name="DivPath">
              <item name="path_menu">@array/path_menu</item>
              <item name="path_icon">@drawable/view_path_button</item>
              <item name="path_icon_anim">true</item>
              <item name="path_anim">300</item>
              <item name="path_radius">120</item>
              <item name="path_mode">BottomCenter</item>
          </style>

  2. 属性配置例子
    • 布局文件
    • <?xml version="1.0" encoding="utf-8"?>
      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical" >
      
          <General.View.PathLayout
              android:id="@+id/path"
              style="@style/MyDivPath"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical" />
      
      </RelativeLayout>

    • 样式
    • <?xml version="1.0" encoding="utf-8"?>
      <resources>
      
          <!-- 自定义序列 -->
          <integer-array name="div_path_menu">
              <item>-1</item>
              <item>@drawable/path_question</item>
              <item>@drawable/path_photo</item>
              <item>@drawable/path_people</item>
              <item>@drawable/path_pet</item>
              <item>-1</item>
          </integer-array>
      
          <style name="MyDivPath" parent="@style/DivPath">
              <item name="path_menu">@array/div_path_menu</item>
              <item name="path_icon">@drawable/path_menu</item>
              <item name="path_anim">300</item>
              <item name="path_radius">180</item>
              <item name="path_mode">BottomCenter</item>
          </style>
      
      </resources>

  3. 监听点击事件
    • 		PathLayout mPathLayout = (PathLayout) this.findViewById(R.id.path);
      		mPathLayout.show();
      		OnClickListener mListener = new OnClickListener() {
      
      			@Override
      			public void onClick(View v) {
      				// TODO Auto-generated method stub
      				int mId = v.getId();
      				if (mId == R.drawable.path_pet) {
      					MyLog.show(PathActivity.this, "path_pet");
      				} else if (mId == R.drawable.path_photo) {
      					MyLog.show(PathActivity.this, "path_photo");
      				} else if (mId == R.drawable.path_people) {
      					MyLog.show(PathActivity.this, "path_people");
      				} else if (mId == R.drawable.path_question) {
      					MyLog.show(PathActivity.this, "path_question");
      				}
      			}
      
      		};
      		mPathLayout.setButtonsOnClickListener(mListener);

  4. 效果图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值