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

The following examples show how to use android.widget.TextView#getTranslationY() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@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
@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
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

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