diff options
| author | Adam Powell <adamp@google.com> | 2016-08-15 16:34:37 -0700 |
|---|---|---|
| committer | Ned Burns <pixel@google.com> | 2016-08-23 18:36:04 -0400 |
| commit | 2fe301db7555bccf53e465436d4cb7442c803df3 (patch) | |
| tree | bcefc11016f83e18b4af5e96118c3ac653ce6465 /core/java/android/widget/ScrollView.java | |
| parent | b8e74df82d9cbe1d6dc157c49f1d47a4aa4740e7 (diff) | |
Focus behavior for scroll containers in watch mode
Change default scrolling containers not to request a reveal (parent
scroll) on focus, and to be focusable in touch mode. This helps watch
devices with other input mechanisms that rely on view focus.
Since there's no attribute for the reveal on focus hint, set that in
code. Set focusable in touch mode on the default styles for
ScrollView/HorizontalScrollView. AbsListView already sets this
historically anyway.
Change-Id: I74760f6d523874127da6f6134f0461cc59ce189a
Diffstat (limited to 'core/java/android/widget/ScrollView.java')
| -rw-r--r-- | core/java/android/widget/ScrollView.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java index 0555cd403b00..493b28c688f9 100644 --- a/core/java/android/widget/ScrollView.java +++ b/core/java/android/widget/ScrollView.java @@ -17,6 +17,7 @@ package android.widget; import android.annotation.NonNull; +import android.content.res.Configuration; import android.os.Build; import android.os.Build.VERSION_CODES; import android.os.Parcel; @@ -186,6 +187,10 @@ public class ScrollView extends FrameLayout { setFillViewport(a.getBoolean(R.styleable.ScrollView_fillViewport, false)); a.recycle(); + + if (context.getResources().getConfiguration().uiMode == Configuration.UI_MODE_TYPE_WATCH) { + setRevealOnFocusHint(false); + } } @Override @@ -1455,11 +1460,13 @@ public class ScrollView extends FrameLayout { @Override public void requestChildFocus(View child, View focused) { - if (!mIsLayoutDirty) { - scrollToChild(focused); - } else { - // The child may not be laid out yet, we can't compute the scroll yet - mChildToScrollTo = focused; + if (focused.getRevealOnFocusHint()) { + if (!mIsLayoutDirty) { + scrollToChild(focused); + } else { + // The child may not be laid out yet, we can't compute the scroll yet + mChildToScrollTo = focused; + } } super.requestChildFocus(child, focused); } |
