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