扩展的思路 可以看我的简书
下载demo ##特色
- 支持多级菜单
- 你可以完全自定义你的菜单样式,我这里只是封装了一些实用的方法,Tab的切换效果,菜单显示隐藏效果等
- 并非用popupWindow实现,无卡顿
##ScreenShot
##本fork项目扩展
- 支持 tabView的样式扩展
应读者要求加了箭头在文本的方向属性以及分隔线高度属性
为popupWindows集合的view增加了对LayoutParams的支持。
- 支持手动添加非下拉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
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.