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;
}
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());
}
});
}
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;
}
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);
}
}
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();
}
Aggregations