本文整理汇总了Java中android.view.View.setLayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java View.setLayoutParams方法的具体用法?Java View.setLayoutParams怎么用?Java View.setLayoutParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.setLayoutParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setRenderView
import android.view.View; //导入方法依赖的package包/类
public void setRenderView(IRenderView renderView) {
if (this.mRenderView != null) {
if (this.mMediaPlayer != null) {
this.mMediaPlayer.setDisplay(null);
}
View renderUIView = this.mRenderView.getView();
this.mRenderView.removeRenderCallback(this.mSHCallback);
this.mRenderView = null;
removeView(renderUIView);
}
if (renderView != null) {
this.mRenderView = renderView;
renderView.setAspectRatio(this.mCurrentAspectRatio);
if (this.mVideoWidth > 0 && this.mVideoHeight > 0) {
renderView.setVideoSize(this.mVideoWidth, this.mVideoHeight);
}
if (this.mVideoSarNum > 0 && this.mVideoSarDen > 0) {
renderView.setVideoSampleAspectRatio(this.mVideoSarNum, this.mVideoSarDen);
}
renderUIView = this.mRenderView.getView();
renderUIView.setLayoutParams(new LayoutParams(-2, -2, 17));
addView(renderUIView);
this.mRenderView.addRenderCallback(this.mSHCallback);
this.mRenderView.setVideoRotation(this.mVideoRotationDegree);
}
}
示例2: setViewMargin
import android.view.View; //导入方法依赖的package包/类
/**
* 设置View的Margin
*
* @param view
* @param left
* @param top
* @param right
* @param bottom
* @param width
* @param height
*/
public void setViewMargin(View view, int left, int top, int right, int bottom, int width, int height) {
if (view == null) {
return;
}
ViewParent parent = view.getParent();
if (parent == null) {
return;
}
ViewGroup.MarginLayoutParams lp;
if (parent instanceof LinearLayout) {
lp = new LinearLayout.LayoutParams(width, height);
} else if (parent instanceof RelativeLayout) {
lp = new RelativeLayout.LayoutParams(width, height);
} else if (parent instanceof FrameLayout) {
lp = new FrameLayout.LayoutParams(width, height);
} else {
lp = new TableLayout.LayoutParams(width, height);
}
if (lp != null) {
lp.setMargins(left, top, right, bottom);
view.setLayoutParams(lp);
}
}
示例3: initView
import android.view.View; //导入方法依赖的package包/类
private void initView(Context context) {
View.inflate(context, R.layout.bar_activity_title, this);
mTvTitle = (TextView) findViewById(R.id.tv_title);
View statusBar = findViewById(R.id.status_bar);
final GoBackActivity act = (GoBackActivity) context;
ViewGroup.LayoutParams layoutParams = statusBar.getLayoutParams();
layoutParams.height = ScreenUtil.getStatusBarHeight(act);
statusBar.setLayoutParams(layoutParams);
findViewById(R.id.tv_back).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
act.onBackPressed();
}
});
}
示例4: wrapChild
import android.view.View; //导入方法依赖的package包/类
private View wrapChild(View child) {
if (!mOutlineEnabled || child instanceof OutlineContainer) return child;
OutlineContainer out = new OutlineContainer(getContext());
out.setLayoutParams(generateDefaultLayoutParams());
child.setLayoutParams(new OutlineContainer.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
out.addView(child);
return out;
}
示例5: getHeader
import android.view.View; //导入方法依赖的package包/类
@Override
public View getHeader(RecyclerView parent, int position) {
long headerId = mAdapter.getHeaderId(position);
View header = mHeaderViews.get(headerId);
if (header == null) {
//TODO - recycle views
RecyclerView.ViewHolder viewHolder = mAdapter.onCreateHeaderViewHolder(parent);
mAdapter.onBindHeaderViewHolder(viewHolder, position);
header = viewHolder.itemView;
if (header.getLayoutParams() == null) {
header.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
int widthSpec;
int heightSpec;
if (mOrientationProvider.getOrientation(parent) == LinearLayoutManager.VERTICAL) {
widthSpec = View.MeasureSpec.makeMeasureSpec(parent.getWidth(), View.MeasureSpec.EXACTLY);
heightSpec = View.MeasureSpec.makeMeasureSpec(parent.getHeight(), View.MeasureSpec.UNSPECIFIED);
} else {
widthSpec = View.MeasureSpec.makeMeasureSpec(parent.getWidth(), View.MeasureSpec.UNSPECIFIED);
heightSpec = View.MeasureSpec.makeMeasureSpec(parent.getHeight(), View.MeasureSpec.EXACTLY);
}
int childWidth = ViewGroup.getChildMeasureSpec(widthSpec,
parent.getPaddingLeft() + parent.getPaddingRight(), header.getLayoutParams().width);
int childHeight = ViewGroup.getChildMeasureSpec(heightSpec,
parent.getPaddingTop() + parent.getPaddingBottom(), header.getLayoutParams().height);
header.measure(childWidth, childHeight);
header.layout(0, 0, header.getMeasuredWidth(), header.getMeasuredHeight());
mHeaderViews.put(headerId, header);
}
return header;
}
示例6: wrap
import android.view.View; //导入方法依赖的package包/类
public static SwipeBackLayout wrap(View child, int edgeFlag) {
SwipeBackLayout wrapper = new SwipeBackLayout(child.getContext());
wrapper.setEdgeTrackingEnabled(edgeFlag);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
child.setLayoutParams(lp);
wrapper.addView(child);
wrapper.setContentView(child);
return wrapper;
}
示例7: onLayoutChange
import android.view.View; //导入方法依赖的package包/类
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (right - left == oldRight - oldLeft) {
return;
}
int cellWidth = mGrid.getWidth() / columnCount;
for (int i = 0; i < mGrid.getChildCount(); ++i) {
View cell = mGrid.getChildAt(i);
GridLayout.LayoutParams lp = (GridLayout.LayoutParams) cell.getLayoutParams();
lp.width = cellWidth;
cell.setLayoutParams(lp);
}
}
示例8: setView
import android.view.View; //导入方法依赖的package包/类
public static void setView(View view, int width, int height) {
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
layoutParams.height = height;
layoutParams.width = width;
view.setLayoutParams(layoutParams);
if (view.getParent() != null) {
view.getParent().requestLayout();
}
}
示例9: onCreateViewHolder
import android.view.View; //导入方法依赖的package包/类
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = layoutInflater.inflate(R.layout.item_rv_date, parent, false);
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
layoutParams.width = PixelUtil.getWidth(context) / 4;
view.setLayoutParams(layoutParams);
MyViewHolder viewHolder = new MyViewHolder(view);
return viewHolder;
}
示例10: resize
import android.view.View; //导入方法依赖的package包/类
static void resize(View view, int size, int margin) {
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
layoutParams.rightMargin = margin;
layoutParams.width = size;
layoutParams.height = size;
view.setLayoutParams(layoutParams);
}
示例11: addFreshViewLayoutParams
import android.view.View; //导入方法依赖的package包/类
protected void addFreshViewLayoutParams(View view) {
ViewGroup.LayoutParams lp = view.getLayoutParams();
if (lp == null) {
lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
view.setLayoutParams(lp);
}
}
示例12: initializeColorSeekBar
import android.view.View; //导入方法依赖的package包/类
private void initializeColorSeekBar(Palette palette) {
int defaultColor = 0x000000;
int[] colors = {
palette.getDominantColor(defaultColor),
palette.getVibrantColor(defaultColor),
palette.getMutedColor(defaultColor)};
int px = ivPreview.getHeight() - (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 16, getResources().getDisplayMetrics());
sbColor = new ColorSeekBar(PreviewActivity.this);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.setMargins(0, px, 0, 0);
sbColor.setLayoutParams(params);
sbColor.setColorSeeds(colors);
sbColor.setBackground(ContextCompat.getDrawable(PreviewActivity.this, R.drawable.transparent));
sbColor.setOnColorChangeListener(new ColorSeekBar.OnColorChangeListener() {
@Override
public void onColorChangeListener(int colorBarPosition, int alphaBarPosition, int color) {
presenter.setColor(color);
}
});
px = ivPreview.getHeight() - (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics());
int h = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
vSeekBarBacking = new View(PreviewActivity.this);
params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, h);
params.setMargins(0, px, 0, 0);
vSeekBarBacking.setLayoutParams(params);
GradientDrawable gradient = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, colors);
gradient.setCornerRadius(0f);
vSeekBarBacking.setBackground(gradient);
rlRoot.addView(vSeekBarBacking);
rlRoot.addView(sbColor);
}
示例13: setupStatusBarView
import android.view.View; //导入方法依赖的package包/类
private void setupStatusBarView(Context context, ViewGroup decorViewGroup) {
mStatusBarTintView = new View(context);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, mConfig.getStatusBarHeight());
params.gravity = Gravity.TOP;
if (mNavBarAvailable && !mConfig.isNavigationAtBottom()) {
params.rightMargin = mConfig.getNavigationBarWidth();
}
mStatusBarTintView.setLayoutParams(params);
mStatusBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR);
mStatusBarTintView.setVisibility(View.GONE);
decorViewGroup.addView(mStatusBarTintView);
}
示例14: createContentView
import android.view.View; //导入方法依赖的package包/类
@Override
protected View createContentView(ViewGroup parent) {
View view = LayoutInflater.from(getContext()).inflate(R.layout.layout_bottom_popup, parent, false);
LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.BOTTOM;
view.setLayoutParams(lp);
view.setVisibility(INVISIBLE);
return view;
}
示例15: setupStatusBarView
import android.view.View; //导入方法依赖的package包/类
private void setupStatusBarView(Context context, ViewGroup decorViewGroup) {
mStatusBarTintView = new View(context);
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, mConfig.getStatusBarHeight());
params.gravity = Gravity.TOP;
if (mNavBarAvailable && !mConfig.isNavigationAtBottom()) {
params.rightMargin = mConfig.getNavigationBarWidth();
}
mStatusBarTintView.setLayoutParams(params);
mStatusBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR);
mStatusBarTintView.setVisibility(View.GONE);
decorViewGroup.addView(mStatusBarTintView);
}