Search in sources :

Example 61 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project TwinklingRefreshLayout by lcodecorex.

the class ScrollingUtil method getRecyclerViewItemTopInset.

/**
     * 通过反射获取RecyclerView的item的topInset
     *
     * @param layoutParams
     * @return
     */
private static int getRecyclerViewItemTopInset(RecyclerView.LayoutParams layoutParams) {
    try {
        Field field = RecyclerView.LayoutParams.class.getDeclaredField("mDecorInsets");
        field.setAccessible(true);
        // 开发者自定义的滚动监听器
        Rect decorInsets = (Rect) field.get(layoutParams);
        return decorInsets.top;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return 0;
}
Also used : Field(java.lang.reflect.Field) Rect(android.graphics.Rect) RecyclerView(android.support.v7.widget.RecyclerView)

Example 62 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project Android-ObservableScrollView by ksoichiro.

the class FlexibleSpaceToolbarWebViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_flexiblespacetoolbarwebview);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    ActionBar ab = getSupportActionBar();
    if (ab != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
    mFlexibleSpaceView = findViewById(R.id.flexible_space);
    mTitleView = (TextView) findViewById(R.id.title);
    mTitleView.setText(getTitle());
    setTitle(null);
    mToolbarView = findViewById(R.id.toolbar);
    mWebViewContainer = findViewById(R.id.webViewContainer);
    final ObservableScrollView scrollView = (ObservableScrollView) findViewById(R.id.scroll);
    scrollView.setScrollViewCallbacks(this);
    WebView webView = (WebView) findViewById(R.id.webView);
    webView.loadUrl("file:///android_asset/lipsum.html");
    mFlexibleSpaceHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_height);
    int flexibleSpaceAndToolbarHeight = mFlexibleSpaceHeight + getActionBarSize();
    final FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) webView.getLayoutParams();
    layoutParams.topMargin = flexibleSpaceAndToolbarHeight;
    webView.setLayoutParams(layoutParams);
    mFlexibleSpaceView.getLayoutParams().height = flexibleSpaceAndToolbarHeight;
    ScrollUtils.addOnGlobalLayoutListener(mTitleView, new Runnable() {

        @Override
        public void run() {
            updateFlexibleSpaceText(scrollView.getCurrentScrollY());
        }
    });
}
Also used : ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) FrameLayout(android.widget.FrameLayout) WebView(android.webkit.WebView) ActionBar(android.support.v7.app.ActionBar)

Example 63 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project UltimateAndroid by cymcsg.

the class TwoWayLayoutManager method makeAndAddView.

private View makeAndAddView(int position, Direction direction, Recycler recycler) {
    final View child = recycler.getViewForPosition(position);
    final boolean isItemRemoved = ((LayoutParams) child.getLayoutParams()).isItemRemoved();
    if (!isItemRemoved) {
        addView(child, (direction == Direction.END ? -1 : 0));
    }
    setupChild(child, direction);
    if (!isItemRemoved) {
        updateLayoutEdgesFromNewChild(child);
    }
    return child;
}
Also used : LayoutParams(android.support.v7.widget.RecyclerView.LayoutParams) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 64 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project UltimateAndroid by cymcsg.

the class BaseLayoutManager method layoutChild.

@Override
protected void layoutChild(View child, Direction direction) {
    getLaneForChild(mTempLaneInfo, child, direction);
    mLanes.getChildFrame(mChildFrame, getDecoratedMeasuredWidth(child), getDecoratedMeasuredHeight(child), mTempLaneInfo, direction);
    final ItemEntry entry = cacheChildFrame(child, mChildFrame);
    layoutDecorated(child, mChildFrame.left, mChildFrame.top, mChildFrame.right, mChildFrame.bottom);
    final LayoutParams lp = (LayoutParams) child.getLayoutParams();
    if (!lp.isItemRemoved()) {
        pushChildFrame(entry, mChildFrame, mTempLaneInfo.startLane, getLaneSpanForChild(child), direction);
    }
}
Also used : LayoutParams(android.support.v7.widget.RecyclerView.LayoutParams) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams)

Example 65 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project UltimateRecyclerView by cymcsg.

the class UltimateRecyclerView method moveToolbar.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
protected void moveToolbar(final Toolbar mToolbar, final UltimateRecyclerView ultimateRecyclerView, final int screenheight, float toTranslationY) {
    if (ViewCompat.getTranslationY(mToolbar) == toTranslationY) {
        return;
    }
    ValueAnimator animator = ValueAnimator.ofFloat(ViewCompat.getTranslationY(mToolbar), toTranslationY).setDuration(200);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float translationY = (float) animation.getAnimatedValue();
            ViewCompat.setTranslationY(mToolbar, translationY);
            ViewCompat.setTranslationY((View) ultimateRecyclerView, translationY);
            // FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) ((View) ultimateRecyclerView).getLayoutParams();
            MarginLayoutParams layoutParams = (MarginLayoutParams) ((View) ultimateRecyclerView).getLayoutParams();
            layoutParams.height = (int) -translationY + screenheight - layoutParams.topMargin;
            ((View) ultimateRecyclerView).requestLayout();
        }
    });
    animator.start();
}
Also used : ValueAnimator(android.animation.ValueAnimator) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TargetApi(android.annotation.TargetApi)

Aggregations

View (android.view.View)86 RecyclerView (android.support.v7.widget.RecyclerView)78 TextView (android.widget.TextView)24 ViewGroup (android.view.ViewGroup)23 ImageView (android.widget.ImageView)20 LayoutParams (android.support.v7.widget.RecyclerView.LayoutParams)13 FrameLayout (android.widget.FrameLayout)10 Toolbar (android.support.v7.widget.Toolbar)9 Rect (android.graphics.Rect)8 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)8 LinearLayout (android.widget.LinearLayout)8 BindView (butterknife.BindView)8 ActionMenuView (android.support.v7.widget.ActionMenuView)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)7 MarginLayoutParams (android.view.ViewGroup.MarginLayoutParams)6 EditText (android.widget.EditText)6 CollapsibleActionView (android.support.v7.view.CollapsibleActionView)5 MenuView (android.support.v7.view.menu.MenuView)5 ImageView (carbon.widget.ImageView)5 TextView (carbon.widget.TextView)5