Search in sources :

Example 86 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project AStickyHeader by DWorkS.

the class SectionedGridAdapter method getView.

@Override
public View getView(final int position, final View convertView, final ViewGroup parent) {
    View view = null;
    if (isSectionHeaderPosition(position)) {
        final Section section = mSections.get(position);
        LayoutParams layoutParams;
        switch(section.type) {
            case TYPE_HEADER:
                view = handleSectionHeaderView(convertView, section, parent);
                layoutParams = view.getLayoutParams();
                layoutParams.width = getHeaderSize();
                view.setLayoutParams(layoutParams);
                view.setVisibility(View.VISIBLE);
                break;
            case TYPE_HEADER_FILLER:
                view = convertView;
                if (view == null) {
                    view = new View(mContext);
                    view.setLayoutParams(new AbsListView.LayoutParams(0, mHeaderHeight));
                }
                break;
            case TYPE_FILLER:
                view = convertView;
                if (view == null) {
                    view = new View(mContext);
                    view.setLayoutParams(new AbsListView.LayoutParams(0, mNormalCellHeight));
                }
                final boolean lastInRow = position % mNumColumns == mNumColumns - 1;
                layoutParams = view.getLayoutParams();
                layoutParams.width = lastInRow ? LayoutParams.MATCH_PARENT : 0;
                view.setLayoutParams(layoutParams);
                break;
        }
    } else {
        view = mBaseAdapter.getView(sectionedPositionToPosition(position), convertView, parent);
        final LayoutParams layoutParams = view.getLayoutParams();
        layoutParams.height = mNormalCellHeight;
        layoutParams.width = mColumnWidth;
        view.setLayoutParams(layoutParams);
    }
    return view;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) AbsListView(android.widget.AbsListView) GridView(android.widget.GridView) AbsListView(android.widget.AbsListView) PinnedSectionGridView(dev.dworks.libs.astickyheader.ui.PinnedSectionGridView) View(android.view.View) ListView(android.widget.ListView)

Example 87 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project RxBinding by JakeWharton.

the class RxSwipeRefreshLayoutTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    swipeRefreshLayout = new SwipeRefreshLayout(this);
    swipeRefreshLayout.setId(R.id.swipe_refresh_layout);
    swipeRefreshLayout.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_UP) {
                handler.removeCallbacks(stopRefreshing);
                handler.postDelayed(stopRefreshing, 300);
            }
            return false;
        }
    });
    ScrollView scrollView = new ScrollView(this);
    LayoutParams scrollParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
    swipeRefreshLayout.addView(scrollView, scrollParams);
    FrameLayout emptyView = new FrameLayout(this);
    LayoutParams emptyParams = new LayoutParams(MATCH_PARENT, 100000);
    scrollView.addView(emptyView, emptyParams);
    setContentView(swipeRefreshLayout);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) ScrollView(android.widget.ScrollView) FrameLayout(android.widget.FrameLayout) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ScrollView(android.widget.ScrollView) View(android.view.View) MotionEvent(android.view.MotionEvent)

Example 88 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project RxBinding by JakeWharton.

the class RxAutoCompleteTextViewTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    setContentView(layout);
    autoCompleteTextView = new AutoCompleteTextView(this);
    autoCompleteTextView.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
    autoCompleteTextView.setId(R.id.auto_complete);
    layout.addView(autoCompleteTextView);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) LinearLayout(android.widget.LinearLayout) AutoCompleteTextView(android.widget.AutoCompleteTextView)

Example 89 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project bilibili-android-client by HotBitmapGG.

the class VideoPlayerView method setVideoLayout.

public void setVideoLayout(int layout) {
    LayoutParams lp = getLayoutParams();
    Pair<Integer, Integer> res = ScreenResolution.getResolution(mContext);
    int windowWidth = res.first, windowHeight = res.second;
    float windowRatio = windowWidth / (float) windowHeight;
    int sarNum = mVideoSarNum;
    int sarDen = mVideoSarDen;
    if (mVideoHeight > 0 && mVideoWidth > 0) {
        float videoRatio = ((float) (mVideoWidth)) / mVideoHeight;
        if (sarNum > 0 && sarDen > 0) {
            videoRatio = videoRatio * sarNum / sarDen;
        }
        mSurfaceHeight = mVideoHeight;
        mSurfaceWidth = mVideoWidth;
        if (VIDEO_LAYOUT_ORIGIN == layout && mSurfaceWidth < windowWidth && mSurfaceHeight < windowHeight) {
            lp.width = (int) (mSurfaceHeight * videoRatio);
            lp.height = mSurfaceHeight;
        } else if (layout == VIDEO_LAYOUT_ZOOM) {
            lp.width = windowRatio > videoRatio ? windowWidth : (int) (videoRatio * windowHeight);
            lp.height = windowRatio < videoRatio ? windowHeight : (int) (windowWidth / videoRatio);
        } else {
            boolean full = layout == VIDEO_LAYOUT_STRETCH;
            lp.width = (full || windowRatio < videoRatio) ? windowWidth : (int) (videoRatio * windowHeight);
            lp.height = (full || windowRatio > videoRatio) ? windowHeight : (int) (windowWidth / videoRatio);
        }
        setLayoutParams(lp);
        getHolder().setFixedSize(mSurfaceWidth, mSurfaceHeight);
        DebugLog.dfmt(TAG, "VIDEO: %dx%dx%f[SAR:%d:%d], Surface: %dx%d, LP: %dx%d, Window: %dx%dx%f", mVideoWidth, mVideoHeight, videoRatio, mVideoSarNum, mVideoSarDen, mSurfaceWidth, mSurfaceHeight, lp.width, lp.height, windowWidth, windowHeight, windowRatio);
    }
    mVideoLayout = layout;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams)

Example 90 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project AndroidChromium by JackyAndroid.

the class StackViewAnimation method createNewTabOpenedAnimator.

private Animator createNewTabOpenedAnimator(StackTab[] tabs, ViewGroup container, TabModel model, int focusIndex) {
    Tab tab = model.getTabAt(focusIndex);
    if (tab == null || !tab.isNativePage())
        return null;
    View view = tab.getView();
    if (view == null)
        return null;
    // Set up the view hierarchy
    if (view.getParent() != null)
        ((ViewGroup) view.getParent()).removeView(view);
    ViewGroup bgView = new FrameLayout(view.getContext());
    bgView.setBackgroundColor(tab.getBackgroundColor());
    bgView.addView(view);
    container.addView(bgView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    // Update any compositor state that needs to change
    if (tabs != null && focusIndex >= 0 && focusIndex < tabs.length) {
        tabs[focusIndex].setAlpha(0.f);
    }
    // Build the view animations
    PropertyValuesHolder xScale = PropertyValuesHolder.ofFloat(View.SCALE_X, 0.f, 1.f);
    PropertyValuesHolder yScale = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.f, 1.f);
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0.f, 1.f);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(bgView, xScale, yScale, alpha);
    animator.setDuration(TAB_OPENED_ANIMATION_DURATION);
    animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_FOLLOW_THROUGH_CURVE);
    float insetPx = TAB_OPENED_PIVOT_INSET_DP * mDpToPx;
    bgView.setPivotY(TAB_OPENED_PIVOT_INSET_DP);
    bgView.setPivotX(LocalizationUtils.isLayoutRtl() ? mWidthDp * mDpToPx - insetPx : insetPx);
    return animator;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) Tab(org.chromium.chrome.browser.tab.Tab) ViewGroup(android.view.ViewGroup) ObjectAnimator(android.animation.ObjectAnimator) FrameLayout(android.widget.FrameLayout) PropertyValuesHolder(android.animation.PropertyValuesHolder) View(android.view.View)

Aggregations

LayoutParams (android.view.ViewGroup.LayoutParams)265 TextView (android.widget.TextView)56 View (android.view.View)50 ViewGroup (android.view.ViewGroup)50 FrameLayout (android.widget.FrameLayout)35 LinearLayout (android.widget.LinearLayout)33 ImageView (android.widget.ImageView)30 Test (org.junit.Test)26 Paint (android.graphics.Paint)22 ListView (android.widget.ListView)22 ScrollView (android.widget.ScrollView)22 Context (android.content.Context)19 MarginLayoutParams (android.view.ViewGroup.MarginLayoutParams)19 AdapterView (android.widget.AdapterView)17 RelativeLayout (android.widget.RelativeLayout)14 DisplayMetrics (android.util.DisplayMetrics)12 CheckedTextView (android.widget.CheckedTextView)12 Rect (android.graphics.Rect)9 ViewParent (android.view.ViewParent)9 TypedArray (android.content.res.TypedArray)8