Skip to content

keyboard3/DropDownMenu

 
 

Repository files navigation

简介

扩展的思路 可以看我的简书

下载

demo.apk

特色

  • 支持多级菜单
  • 你可以完全自定义你的菜单样式,我这里只是封装了一些实用的方法,Tab的切换效果,菜单显示隐藏效果等
  • 非用popupWindow实现,无卡顿

截图

扩展

箭头居中而不是居最右

icon方向属性

分隔线高度属性

为popupWindows集合的view增加了对LayoutParams的支持

支持手动添加非下拉tabView

使用

注意:此布局需要作为根布局才可能覆盖内容区域

  • 样式扩展 添加名为tab_item.xml到你的布局文件,在要显示内容的TextView上设置id为R.id.tv_tab。tab_item.xml中 任意布局即可。
    tab_item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:gravity="center">
    <TextView
        android:id="@+id/tv_tab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawablePadding="7dp"
        android:gravity="center"
        android:paddingBottom="12dp"
        android:paddingLeft="5dp"
        android:paddingRight="5dp"
        android:paddingTop="12dp"
        android:textColor="#26a8e0" />
</LinearLayout>
  • 手动添加非下拉tabView tab_text.xml设置样式/也可以代码生成,加载控件添加到DropDownMenu中
    tab_text
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:drawablePadding="7dp"
    android:gravity="center"
    android:paddingBottom="12dp"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:paddingTop="12dp"
    android:textColor="#26a8e0"
    xmlns:android="http://schemas.android.com/apk/res/android" />

调用添加,在setDropDownMenu之后添加

...
//init dropdownview
 mDropDownMenu.setDropDownMenu(Arrays.asList(headers), popupViews, contentView);
 //测试tabView扩展功能
 TextView textView= (TextView) getLayoutInflater().inflate(R.layout.tab_text,null);
 textView.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1.0f));
 textView.setText("所有");
 mDropDownMenu.addTab(textView,0);
 textView.setOnClickListener(new View.OnClickListener() {
       @Override
       public void onClick(View view) {
           mDropDownMenu.closeMenu();
       }
   });

如果你要了解更多,可以直接看源码 Example

关于我

简书 keyboard3
邮箱 keyboard3@icloud.com

致谢

About

扩展之后的 多条件筛选菜单

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%