android - Adding press selector to DelayedConfirmationView -
i can't find way add press effect delayedconfirmationview
. tried using selector on app:circle_color
pressed color doesn't appear on click.
here xmls
delayedconfirmationview:
<android.support.wearable.view.delayedconfirmationview android:id="@+id/confirmation_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:src="@drawable/ic_close_white_48dp" app:circle_color="@drawable/selector_confirmation_view" app:circle_radius="@dimen/circular_button_radius" app:circle_radius_pressed="@dimen/circular_button_radius" app:circle_padding="6dp" app:circle_border_width="4dp" app:circle_border_color="@color/white" />
selector:
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:color="@color/dark_blue" android:state_pressed="true" /> <item android:color="@color/blue" /> </selector>
so, how add press effect view?
p.s. seems work on circledimageview
you can see example of usage of delayedconfirmationview
in official samples: samples\android-22\wearable\delayedconfirmation
reason
delayedconfirmationview
not normal button , pressed state not applied default on standard buttons.
to listen clicks on there special delayedconfirmationlistener
set via setlistener(delayedconfirmationlistener)
method. need implement 2 methods there:
ontimerselected(view)
- triggered once user touches button (just touch down, not full click).delayedconfirmationview
started right after becomes visible user (after requesting action example voice) , has little time cancel action. reacting on touch down instead of full click nice way user interrupting action possible.ontimerfinished(view)
- called when times finished.
solution
if want changed state pressed on touch down need following thing:
confirmationview.setlistener(new delayedconfirmationview.delayedconfirmationlistener() { @override public void ontimerselected(view view) { confirmationview.setpressed(true); } @override public void ontimerfinished(view view) { // here } });
btw. please move selector /res/drawable/
/res/color/
, change:
app:circle_color="@drawable/selector_confirmation_view"
to:
app:circle_color="@color/selector_confirmation_view"
Comments
Post a Comment