DropDownMenu下拉筛选排序Menu,androidjetpack详解

本文详细介绍了如何创建一个自定义的Android DropDownMenu组件,包括构造方法、属性设置、菜单项的添加以及点击事件处理。通过使用LinearLayout和FrameLayout,结合自定义属性和点击事件监听,实现了下拉筛选菜单的功能。同时,提供了设置菜单文字、颜色、图标的API,并给出了关闭菜单的方法。
摘要由CSDN通过智能技术生成

//tab选中图标

private int menuSelectedIcon;

//tab未选中图标

private int menuUnselectedIcon;

public DropDownMenu(Context context) {

super(context, null);

}

public DropDownMenu(Context context, AttributeSet attrs) {

this(context, attrs, 0);

}

public DropDownMenu(Context context, AttributeSet attrs, int defStyleAttr) {

super(context, attrs, defStyleAttr);

setOrientation(VERTICAL);

//为DropDownMenu添加自定义属性

int menuBackgroundColor = 0xffffffff;

int underlineColor = 0xffcccccc;

TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DropDownMenu);

underlineColor = a.getColor(R.styleable.DropDownMenu_ddunderlineColor, underlineColor);

dividerColor = a.getColor(R.styleable.DropDownMenu_dddividerColor, dividerColor);

textSelectedColor = a.getColor(R.styleable.DropDownMenu_ddtextSelectedColor, textSelectedColor);

textUnselectedColor = a.getColor(R.styleable.DropDownMenu_ddtextUnselectedColor, textUnselectedColor);

menuBackgroundColor = a.getColor(R.styleable.DropDownMenu_ddmenuBackgroundColor, menuBackgroundColor);

maskColor = a.getColor(R.styleable.DropDownMenu_ddmaskColor, maskColor);

menuTextSize = a.getDimensionPixelSize(R.styleable.DropDownMenu_ddmenuTextSize, menuTextSize);

menuSelectedIcon = a.getResourceId(R.styleable.DropDownMenu_ddmenuSelectedIcon, menuSelectedIcon);

menuUnselectedIcon = a

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值