Search in sources :

Example 31 with LayoutParams

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);
    }
}
Also used : Configuration(android.content.res.Configuration) ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) Display(android.view.Display)

Example 32 with LayoutParams

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;
        }
    }
}
Also used : Interpolator(android.view.animation.Interpolator) View(android.view.View) NestedScrollView(android.support.v4.widget.NestedScrollView) RecyclerView(android.support.v7.widget.RecyclerView)

Example 33 with LayoutParams

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);
}
Also used : AppCompatTextView(android.support.v7.widget.AppCompatTextView) AppCompatTextView(android.support.v7.widget.AppCompatTextView) Espresso.onView(android.support.test.espresso.Espresso.onView) View(android.view.View) TestFloatingBehavior(android.support.design.testapp.custom.TestFloatingBehavior) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 34 with LayoutParams

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;
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) GridView(android.widget.GridView) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView) View(android.view.View) ListView(android.widget.ListView) WebView(android.webkit.WebView)

Example 35 with LayoutParams

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;
}
Also used : LayoutParams(android.support.v7.widget.RecyclerView.LayoutParams) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams)

Aggregations

View (android.view.View)138 RecyclerView (android.support.v7.widget.RecyclerView)128 TextView (android.widget.TextView)52 ImageView (android.widget.ImageView)36 LinearLayout (android.widget.LinearLayout)32 ViewGroup (android.view.ViewGroup)31 LayoutParams (android.support.v7.widget.RecyclerView.LayoutParams)16 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)15 FrameLayout (android.widget.FrameLayout)15 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)13 Paint (android.graphics.Paint)12 RelativeLayout (android.widget.RelativeLayout)12 BindView (butterknife.BindView)12 Rect (android.graphics.Rect)11 Toolbar (android.support.v7.widget.Toolbar)11 EditText (android.widget.EditText)10 DialogInterface (android.content.DialogInterface)9 Handler (android.os.Handler)9 AdapterView (android.widget.AdapterView)9 Intent (android.content.Intent)8