Example usage for android.widget TextView setScrollX

List of usage examples for android.widget TextView setScrollX

Introduction

In this page you can find the example usage for android.widget TextView setScrollX.

Prototype

public void setScrollX(int value) 

Source Link

Document

Set the horizontal scrolled position of your view.

Usage

From source file:org.chromium.chrome.browser.toolbar.ToolbarPhone.java

private Property<TextView, Integer> buildUrlScrollProperty(final View containerView,
        final boolean isContainerRtl) {
    // If the RTL-ness of the container view changes during an animation, the scroll values
    // become invalid.  If that happens, snap to the ending position and no longer update.
    return new Property<TextView, Integer>(Integer.class, "scrollX") {
        private boolean mRtlStateInvalid;

        @Override//from w  ww  .  j av a 2  s  .c o m
        public Integer get(TextView view) {
            return view.getScrollX();
        }

        @Override
        public void set(TextView view, Integer scrollX) {
            if (mRtlStateInvalid)
                return;
            boolean rtl = ApiCompatibilityUtils.isLayoutRtl(containerView);
            if (rtl != isContainerRtl) {
                mRtlStateInvalid = true;
                if (!rtl || mUrlBar.getLayout() != null) {
                    scrollX = 0;
                    if (rtl) {
                        scrollX = (int) view.getLayout().getPrimaryHorizontal(0);
                        scrollX -= view.getWidth();
                    }
                }
            }
            view.setScrollX(scrollX);
        }
    };
}