selector android 事件,android – Selector反应缓慢 – 有时在开始下一个活动之前根本不会开火...

我定义了这个Selector:

android:drawable="@drawable/backarrow_blueshiny" />

android:drawable="@drawable/backarrow_blackshiny" />

它与此按钮一起使用:

android:orientation="horizontal"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:background="@drawable/bottomborder_glossy">

android:id="@+id/filter_button_back"

android:layout_width="90dip"

android:layout_height="wrap_content"

android:src="@drawable/selector_back_button"

android:background="#00000000"

android:layout_alignParentLeft="true"

android:layout_alignParentBottom="true"/>

并且onTouch事件包括:

public boolean onTouch(View v, MotionEvent event)

{

final int actionPerformed = event.getAction();

final int widgetID = v.getId();

if (actionPerformed == MotionEvent.ACTION_UP)

{

switch (widgetID)

{

case R.id.filter_button_back:

{

this.finish();

break;

}

}

}

return false;

}

这个按钮的作用是退出当前活动this.finish()

但是,在我的测试中,按钮并不总是切换到“backarrow_blueshiny” – 即按下非常快.

所以问题是选择器的触发速度比onTouch(MotionEvent.ACTION_UP)事件慢.

有什么我可以做的,以确保选择器不“滞后”?

解决方法:

你的意思是比典型的Android选择器行为更懒散吗?根据我的经验,按下按钮之间总会有一点延迟,并且它被选中 – 我认为这是为了避免在你想要滚动时显示触摸事件,但它总是让我感到烦恼.如果它不仅仅是典型的行为,请尝试仅使用一个按钮,将android:background设置为选择器,而不是将android:src设置为选择器的ImageButton.

例如

android:layout_width="90dip"

android:layout_height="wrap_content"

android:background="@drawable/selector_back_button"

android:layout_alignParentLeft="true"

android:layout_alignParentBottom="true"

/>

标签:android

来源: https://codeday.me/bug/20190726/1542892.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值