[TIMOB-19578] Android: Customize Touch Feedback
GitHub Issue | n/a |
---|---|
Type | Technical task |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-09-29T08:40:07.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 6.1.0 |
Components | Android |
Labels | android, material-design, touchfeedback |
Reporter | Chee Kiat Ng |
Assignee | Gary Mathews |
Created | 2015-09-25T03:08:57.000+0000 |
Updated | 2018-08-06T19:38:15.000+0000 |
Description
Touch feedback in material design provides an instantaneous visual confirmation at the point of contact when users interact with UI elements. The default touch feedback animations for buttons use the new RippleDrawable class, which transitions between different states with a ripple effect.
In most cases, you should apply this functionality in your view XML by specifying the view background as:
?android:attr/selectableItemBackground for a bounded ripple.
?android:attr/selectableItemBackgroundBorderless for a ripple that extends beyond the view. It will be drawn upon, and bounded by, the nearest parent of the view with a non-null background.
Note: selectableItemBackgroundBorderless is a new attribute introduced in API level 21.
Alternatively, you can define a RippleDrawable as an XML resource using the ripple element.
You can assign a color to RippleDrawable objects. To change the default touch feedback color, use the theme's android:colorControlHighlight attribute.
For more information, see the API reference for the RippleDrawable class.
PR https://github.com/appcelerator/titanium_mobile/pull/7317 Tested with Kitchen sink suite and below test code
[~hpham] Updated with code review changes. Please review https://github.com/appcelerator/titanium_mobile/pull/7317/
[~hpham] Please review the PR.
[~hpham] Please review resolved merge conflicts PR https://github.com/appcelerator/titanium_mobile/pull/7317/
Will this change enable developers to display touch feedback on ListItems? Or is there a related ticket to enable that functionality. Because the PR is related to the Ti.UI.View component, I suspect not. I'd really like to show touch feedback on a ListView because processing an
itemclick
, say to open a new window, can take a significant amount of time making for bad user experience.The PRs need to be re-reviewed and also possibly rebased.
Updated PR (based on master): https://github.com/appcelerator/titanium_mobile/pull/8176 We can use the above demo-code to review. I also changed the
since
version to 6.1.0, added some docs-improvements and refactored some code-style. [~msamah] Can you proceed with the review then? After 6.0.0 branching I guess.Some FT problems (tested on Sim so far): - When clicking the red button before changing the riffle color to green, I don't see a touch-feedback although
touchFeedback
istrue
already - I see touch-feedback on the default button to change the riffle color, so it might be a problem with (initial) custom colors that are not targeted correctly - I don't see any touch-feedback on both the view and the window, althoughtouchFeedback
istrue
there as well. Is it supposed to work there? I am not sure if that's intended behavior. I took over this PR from Srikanth, but maybe someone from the Android-team could rather help here. Thanks![~hansknoechel] I reviewed and addressed the issues. master: https://github.com/appcelerator/titanium_mobile/pull/8446
Test-case:
Verified, when the touch feedback was enabled the ripple effect was visible on the button; tested using the test case provided by [~hansknoechel]
*Environement*
This is really awesome! Does anyone have an input on how to apply this for ListViews? Thanks!
+1 for the
ListView
. Documentation says it supports it but it clearly doesn't work withItemTemplates
.