use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project platform_frameworks_base by android.
the class NavBarTuner method inflatePreview.
private void inflatePreview(ViewGroup view) {
Display display = getActivity().getWindowManager().getDefaultDisplay();
boolean isRotated = display.getRotation() == Surface.ROTATION_90 || display.getRotation() == Surface.ROTATION_270;
Configuration config = new Configuration(getContext().getResources().getConfiguration());
boolean isPhoneLandscape = isRotated && (config.smallestScreenWidthDp < 600);
final float scale = isPhoneLandscape ? PREVIEW_SCALE_LANDSCAPE : PREVIEW_SCALE;
config.densityDpi = (int) (config.densityDpi * scale);
mPreview = (PreviewNavInflater) LayoutInflater.from(getContext().createConfigurationContext(config)).inflate(R.layout.nav_bar_tuner_inflater, view, false);
final ViewGroup.LayoutParams layoutParams = mPreview.getLayoutParams();
layoutParams.width = (int) ((isPhoneLandscape ? display.getHeight() : display.getWidth()) * scale);
// Not sure why, but the height dimen is not being scaled with the dp, set it manually
// for now.
layoutParams.height = (int) (layoutParams.height * scale);
if (isPhoneLandscape) {
int width = layoutParams.width;
layoutParams.width = layoutParams.height;
layoutParams.height = width;
}
view.addView(mPreview);
if (isRotated) {
mPreview.findViewById(R.id.rot0).setVisibility(View.GONE);
final View rot90 = mPreview.findViewById(R.id.rot90);
} else {
mPreview.findViewById(R.id.rot90).setVisibility(View.GONE);
final View rot0 = mPreview.findViewById(R.id.rot0);
}
}
use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project smooth-app-bar-layout by henrytao-me.
the class SmoothAppBarLayout method onLayout.
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
int i = 0;
for (int z = this.getChildCount(); i < z; ++i) {
View child = this.getChildAt(i);
LayoutParams childLp = (LayoutParams) child.getLayoutParams();
Interpolator interpolator = childLp.getScrollInterpolator();
if (interpolator != null) {
mHaveChildWithInterpolator = true;
break;
}
}
}
use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project material-components-android by material-components.
the class CoordinatorSnackbarWithFabTest method testBehaviorBasedSlidingFromRuntimeApiCall.
@Test
public void testBehaviorBasedSlidingFromRuntimeApiCall() {
// Use a layout in which an AppCompatTextView child doesn't have any configured Behavior
onView(withId(R.id.coordinator_stub)).perform(inflateViewStub(R.layout.design_snackbar_behavior_runtime));
// and configure that Behavior at runtime by setting it on its LayoutParams
final AppCompatTextView textView = (AppCompatTextView) mCoordinatorLayout.findViewById(R.id.text);
final CoordinatorLayout.LayoutParams textViewLp = (CoordinatorLayout.LayoutParams) textView.getLayoutParams();
textViewLp.setBehavior(new TestFloatingBehavior());
// Create and show a snackbar
mSnackbar = Snackbar.make(mCoordinatorLayout, MESSAGE_TEXT, Snackbar.LENGTH_INDEFINITE).setAction(ACTION_TEXT, mock(View.OnClickListener.class));
SnackbarUtils.showTransientBottomBarAndWaitUntilFullyShown(mSnackbar);
verifySnackbarViewStacking(textView, 0);
}
use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project TwinklingRefreshLayout by lcodecorex.
the class ScrollingUtil method isRecyclerViewToTop.
public static boolean isRecyclerViewToTop(RecyclerView recyclerView) {
if (recyclerView != null) {
RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
if (manager == null) {
return true;
}
if (manager.getItemCount() == 0) {
return true;
}
if (manager instanceof LinearLayoutManager) {
LinearLayoutManager layoutManager = (LinearLayoutManager) manager;
int firstChildTop = 0;
if (recyclerView.getChildCount() > 0) {
// 处理item高度超过一屏幕时的情况
View firstVisibleChild = recyclerView.getChildAt(0);
if (firstVisibleChild != null && firstVisibleChild.getMeasuredHeight() >= recyclerView.getMeasuredHeight()) {
if (android.os.Build.VERSION.SDK_INT < 14) {
return !(ViewCompat.canScrollVertically(recyclerView, -1) || recyclerView.getScrollY() > 0);
} else {
return !ViewCompat.canScrollVertically(recyclerView, -1);
}
}
// 如果RecyclerView的子控件数量不为0,获取第一个子控件的top
// 解决item的topMargin不为0时不能触发下拉刷新
View firstChild = recyclerView.getChildAt(0);
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) firstChild.getLayoutParams();
firstChildTop = firstChild.getTop() - layoutParams.topMargin - getRecyclerViewItemTopInset(layoutParams) - recyclerView.getPaddingTop();
}
if (layoutManager.findFirstCompletelyVisibleItemPosition() < 1 && firstChildTop == 0) {
return true;
}
} else if (manager instanceof StaggeredGridLayoutManager) {
StaggeredGridLayoutManager layoutManager = (StaggeredGridLayoutManager) manager;
int[] out = layoutManager.findFirstCompletelyVisibleItemPositions(null);
if (out[0] < 1) {
return true;
}
}
}
return false;
}
use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project twoway-view by lucasr.
the class BaseLayoutManager method generateLayoutParams.
@Override
public LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) {
final LayoutParams lanedLp = new LayoutParams((MarginLayoutParams) lp);
if (isVertical()) {
lanedLp.width = LayoutParams.MATCH_PARENT;
lanedLp.height = lp.height;
} else {
lanedLp.width = lp.width;
lanedLp.height = LayoutParams.MATCH_PARENT;
}
return lanedLp;
}
Aggregations