android dropdown,GitHub - opticalix/android-dropdown-menu: A dropdown menu for android, you can atta...

android-dropdown-menu

An dropdown menu for android, you can attach your own listView(s) with this.

文档

Demo

687474703a2f2f3778703271632e636f6d312e7a302e676c622e636c6f7564646e2e636f6d2f64726f70646f776e5f64656d6f2e676966

Usage

You can use this to make several(as you want) listViews act like dropdown menu, the 'weight' of titles' width is adjustable. It will not intercept touch events when it get back.

Use this view in xml:

xmlns:app="http://schemas.android.com/apk/res-auto"

android:id="@+id/dropdown_view"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:drop_down_arrow_up="@mipmap/ic_arrow_up"

app:drop_down_duration="200"

app:drop_down_enable_dim="true"

app:drop_down_list_count="2"

app:drop_down_list_height="150dp"

app:drop_down_title_background="@android:color/white"

app:drop_down_title_drawable_padding="10dp"

app:drop_down_title_padding_bottom="7dp"

app:drop_down_title_padding_top="7dp"

app:drop_down_title_text="@array/drop_down_titles"

app:drop_down_title_text_color="#444444"

app:drop_down_title_text_size="10sp"/>

Then find this view and setup():

mDropdownView = (DropdownView) findViewById(R.id.dropdown_view);

mDropdownView.setup(simpleListView1, simpleListView2);

mDropdownView.setOnDropdownItemClickListener(new DropdownView.OnDropdownItemClickListener() {

@Override

public void onItemClick(View v, int whichList, int position) {

mDropdownView.setTitleText(whichList, whichList + "-" + position);

}

});

//enable functions you need. default value is true

mDropdownView.enableDimBackground(true);

mDropdownView.enableAutoBackOnItemClick(true);

Or you can just new DropdownView in code:

DropdownView dropdownView = new DropdownView(this);

dropdownView.setup(3, titles_arr, simpleListView1, simpleListView2, simpleListView3);

root.addView(dropdownView);

Remember to provide listViews, and register onDropdownItemClickListener.

Include

You can use gradle to grab it from maven central:

compile 'com.opticalix.dropdownmenu:dropdown-lib:1.0.1'

Config

You may need to modify part of the DropdownView, methods like 'setTitleBackgroundColor' are available.

optional

titleTextColor

titleTextSize

titleBackground

titlePadding

arrowDrawable

arrowDrawablePadding

listViewHeight

duration

enableDimBackground

enableAutoBackOnItemClick

necessary

listCount

listViews

titleText

Notice

If you find dropdownView is cover by other views in LOLLIPOP, you can:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

mDropdownView.setZ(100);//larger than others

}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值