Git Product home page Git Product logo

dropdownmenu's Introduction

简介

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

下载demo ##特色

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

##ScreenShot

Paste_Image.png

##本fork项目扩展

  • 支持 tabView的样式扩展

箭头居中而不是居最右

应读者要求加了箭头在文本的方向属性以及分隔线高度属性

icon方向属性 效果图

分隔线高度属性 效果图

为popupWindows集合的view增加了对LayoutParams的支持。 代码图 效果图

  • 支持手动添加非下拉tabView

可以在tab位置中插入自己需要的tabView

我们只需要在java代码中调用下面的代码 ##扩展的使用

  • 样式扩展 添加名为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

##关于fork的我 简书keyboard3

dropdownmenu's People

Contributors

dongjunkun avatar keyboard3 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.