Java Code Examples for android.view.ViewGroup.requestChildFocus()

The following are Jave code examples for showing how to use requestChildFocus() of the android.view.ViewGroup class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: chromium-for-android-56-debug-video   File: EditorTextField.java   Source Code and License Vote up 5 votes
@Override
public void scrollToAndFocus() {
    ViewGroup parent = (ViewGroup) getParent();
    if (parent != null) parent.requestChildFocus(this, this);
    requestFocus();
    sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
}
 
Example 2
Project: chromium-for-android-56-debug-video   File: EditorDropdownField.java   Source Code and License Vote up 5 votes
@Override
public void scrollToAndFocus() {
    updateDisplayedError(!isValid());
    UiUtils.hideKeyboard(mDropdown);
    ViewGroup parent = (ViewGroup) mDropdown.getParent();
    if (parent != null) parent.requestChildFocus(mDropdown, mDropdown);
    mDropdown.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
}
 
Example 3
Project: chromium-for-android-56-debug-video   File: FocusAnimator.java   Source Code and License Vote up 5 votes
/** Scroll the layout so that the focused child is on screen. */
private void requestChildFocus() {
    ViewGroup parent = (ViewGroup) mLayout.getParent();
    if (mLayout.getParent() == null) return;

    // Scroll the parent to make the focused child visible.
    if (mFocusedChild != null) parent.requestChildFocus(mLayout, mFocusedChild);

    // {@link View#requestChildFocus} fails to account for children changing their height, so
    // the scroll value may be past the actual maximum.
    int viewportHeight = parent.getBottom() - parent.getTop();
    int scrollMax = Math.max(0, mLayout.getMeasuredHeight() - viewportHeight);
    if (parent.getScrollY() > scrollMax) parent.setScrollY(scrollMax);
}