Java Code Examples for android.widget.TextView#getTranslationY()

The following examples show how to use android.widget.TextView#getTranslationY() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SampleHeaderBehavior.java    From BehaviorDemo with Apache License 2.0 6 votes vote down vote up
@Override
public void onNestedPreScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull TextView child, @NonNull View target, int dx, int dy, @NonNull int[] consumed, int type) {
    super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type);
    if (target instanceof RecyclerView) {
        RecyclerView list = (RecyclerView) target;
        //列表第一个全部可见Item的位置
        int pos = ((LinearLayoutManager) list.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
        if (pos == 0 && pos < lastPosition) {
            downReach = true;
        }

        if (canScroll(child, dy) && pos == 0) {
            float finalY = child.getTranslationY() - dy;
            if (finalY < -child.getHeight()) {
                finalY = -child.getHeight();
                upReach = true;
            } else if (finalY > 0) {
                finalY = 0;
            }
            child.setTranslationY(finalY);
            consumed[1] = dy;
        }
        lastPosition = pos;
    }
}
 
Example 2
Source File: DiscrollvableGreenLayout.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    mGreenView1 = (TextView) findViewById(R.id.greenView1);
    mGreenView1TranslationY = mGreenView1.getTranslationY();
    mGreenColor = getResources().getColor(android.R.color.holo_green_light);
}
 
Example 3
Source File: DiscrollvableGreenLayout.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    mGreenView1 = (TextView) findViewById(R.id.greenView1);
    mGreenView1TranslationY = mGreenView1.getTranslationY();
    mGreenColor = getResources().getColor(android.R.color.holo_green_light);
}