本文整理汇总了Java中android.widget.FrameLayout.LayoutParams类的典型用法代码示例。如果您正苦于以下问题:Java LayoutParams类的具体用法?Java LayoutParams怎么用?Java LayoutParams使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LayoutParams类属于android.widget.FrameLayout包,在下文中一共展示了LayoutParams类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import android.widget.FrameLayout.LayoutParams; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
FrameLayout fl = new FrameLayout(getActivity());
fl.setLayoutParams(params);
final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources()
.getDisplayMetrics());
TextView v = new TextView(getActivity());
params.setMargins(margin, margin, margin, margin);
v.setLayoutParams(params);
v.setLayoutParams(params);
v.setGravity(Gravity.CENTER);
v.setBackgroundResource(R.drawable.background_card);
v.setText("CARD " + (position + 1));
fl.addView(v);
return fl;
}
示例2: init
import android.widget.FrameLayout.LayoutParams; //导入依赖的package包/类
private void init() {
if (!(getLayoutParams() instanceof ViewGroup.LayoutParams)) {
LayoutParams layoutParams =
new LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
setLayoutParams(layoutParams);
}
// the default value
//setPadding(dip2Px(40), dip2Px(2), dip2Px(40), dip2Px(2));
_labelViewContainerID = -1;
setGravity(android.view.Gravity.CENTER);
setTextColor(Color.WHITE);
setTypeface(Typeface.DEFAULT_BOLD);
setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
setBackgroundColor(Color.BLUE);
}
示例3: onCreateView
import android.widget.FrameLayout.LayoutParams; //导入依赖的package包/类
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Context context = getActivity();
FrameLayout root = new FrameLayout(context);
LinearLayout pframe = new LinearLayout(context);
pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
pframe.setOrientation(1);
pframe.setVisibility(8);
pframe.setGravity(17);
pframe.addView(new ProgressBar(context, null, 16842874), new LayoutParams(-2, -2));
root.addView(pframe, new LayoutParams(-1, -1));
FrameLayout lframe = new FrameLayout(context);
lframe.setId(INTERNAL_LIST_CONTAINER_ID);
TextView tv = new TextView(getActivity());
tv.setId(INTERNAL_EMPTY_ID);
tv.setGravity(17);
lframe.addView(tv, new LayoutParams(-1, -1));
ListView lv = new ListView(getActivity());
lv.setId(16908298);
lv.setDrawSelectorOnTop(false);
lframe.addView(lv, new LayoutParams(-1, -1));
root.addView(lframe, new LayoutParams(-1, -1));
root.setLayoutParams(new LayoutParams(-1, -1));
return root;
}
示例4: measure
import android.widget.FrameLayout.LayoutParams; //导入依赖的package包/类
@Override
protected MeasureOutput measure(int width, int height) {
MeasureOutput measureOutput = new MeasureOutput();
if (this.mOrientation == Constants.Orientation.HORIZONTAL) {
int screenW = WXViewUtils.getScreenWidth(WXEnvironment.sApplication);
int weexW = WXViewUtils.getWeexWidth(getInstanceId());
measureOutput.width = width > (weexW >= screenW ? screenW : weexW) ? FrameLayout.LayoutParams.MATCH_PARENT
: width;
measureOutput.height = height;
} else {
int screenH = WXViewUtils.getScreenHeight(WXEnvironment.sApplication);
int weexH = WXViewUtils.getWeexHeight(getInstanceId());
measureOutput.height = height > (weexH >= screenH ? screenH : weexH) ? FrameLayout.LayoutParams.MATCH_PARENT
: height;
measureOutput.width = width;
}
return measureOutput;
}
示例5: onCreate
import android.widget.FrameLayout.LayoutParams; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web);
ButterKnife.bind(this);
initializeToolbar();
mWebView = new WebView(this);
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
mWebView.setLayoutParams(lp);
mContainer.addView(mWebView, 0);
if (Colorful.getThemeDelegate().isNight()) {
mContainer.setAlpha(0.7f);
}
if (getSupportActionBar() != null)
getSupportActionBar().setTitle(getIntent().getStringExtra("title"));
initWebView(getIntent().getStringExtra("url"));
}
示例6: setBrightness
import android.widget.FrameLayout.LayoutParams; //导入依赖的package包/类
/**
* 设置亮度
*
* @param brightness
*/
public void setBrightness(float brightness) {
// if (lp.screenBrightness <= 0.1) {
// return;
// }
WindowManager.LayoutParams lp = act.getWindow().getAttributes();
lp.screenBrightness = lp.screenBrightness + brightness / 255.0f;
if (lp.screenBrightness > 1) {
lp.screenBrightness = 1;
/*
* vibrator = (Vibrator) act.getSystemService("vibrator"); long[]
* pattern = { 10, 200 }; // OFF/ON/OFF/ON... 关闭10秒震动200毫秒,不停切换
* vibrator.vibrate(pattern, -1);
*/
} else if (lp.screenBrightness < 0.2) {
lp.screenBrightness = (float) 0.2;
/*
* vibrator = (Vibrator) act.getSystemService(act.VIBRATOR_SERVICE);
* long[] pattern = { 10, 200 }; // OFF/ON/OFF/ON...
* vibrator.vibrate(pattern, -1);
*/
}
act.getWindow().setAttributes(lp);
}
示例7: BasicNativePage
import android.widget.FrameLayout.LayoutParams; //导入依赖的package包/类
public BasicNativePage(Activity activity, Tab tab) {
initialize(activity, tab);
mActivity = activity;
mTab = tab;
mBackgroundColor = ApiCompatibilityUtils.getColor(activity.getResources(),
R.color.default_primary_color);
mThemeColor = ApiCompatibilityUtils.getColor(
activity.getResources(), R.color.default_primary_color);
Resources res = mActivity.getResources();
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT);
layoutParams.setMargins(0,
res.getDimensionPixelSize(R.dimen.tab_strip_height)
+ res.getDimensionPixelSize(R.dimen.toolbar_height_no_shadow),
0, 0);
getView().setLayoutParams(layoutParams);
}
示例8: hideBottomBar
import android.widget.FrameLayout.LayoutParams; //导入依赖的package包/类
private void hideBottomBar() {
if (mBottomBarView == null) return;
((ViewGroup) mBottomBarView.getParent()).removeView(mBottomBarView);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.BOTTOM;
final ViewGroup compositorView = mActivity.getCompositorViewHolder();
compositorView.addView(mBottomBarView, lp);
compositorView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
compositorView.removeOnLayoutChangeListener(this);
mBottomBarView.animate().alpha(0f).translationY(mBottomBarView.getHeight())
.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE)
.setDuration(SLIDE_ANIMATION_DURATION_MS)
.withEndAction(new Runnable() {
@Override
public void run() {
((ViewGroup) mBottomBarView.getParent()).removeView(mBottomBarView);
mBottomBarView = null;
}
}).start();
}
});
}
示例9: setDate
import android.widget.FrameLayout.LayoutParams; //导入依赖的package包/类
private void setDate(Bitmap bitmap) {
LogInfo.log("RedPacketForecastView", "setDate");
LayoutParams params = new LayoutParams(-2, -2);
params.width = DensityUtil.px2dip(RedPacketSdkManager.getInstance().getApplicationContext(), 74.0f);
params.height = DensityUtil.px2dip(RedPacketSdkManager.getInstance().getApplicationContext(), 74.0f);
setLayoutParams(params);
setImageBitmap(bitmap);
setOnClickListener(new OnClickListener() {
public void onClick(View v) {
LogInfo.log("RedPacketForecastView", "onclick");
StatisticsUtil.statistics(11);
if (RedPacketForecastView.this.mContext != null) {
new RedPacketForecastDialog(RedPacketForecastView.this.mContext, RedPacketForecastView.this.mForecastBean, RedPacketForecastView.this.mDialogDisplayCallback).show();
}
RedPacketForecastView.this.setVisibility(8);
if (RedPacketForecastView.this.mClickCallback != null) {
RedPacketForecastView.this.mClickCallback.onClick();
}
}
});
}
示例10: setRedPacketEntryLocation
import android.widget.FrameLayout.LayoutParams; //导入依赖的package包/类
public void setRedPacketEntryLocation(boolean isLandspace) {
if (this.mRedPacketEntry != null) {
LayoutParams params = (LayoutParams) this.mRedPacketEntry.getLayoutParams();
if (isLandspace) {
params.gravity = 83;
params.leftMargin = DensityUtil.dip2px(this, 23.0f);
params.width = DensityUtil.px2dip(this, 70.0f);
params.height = DensityUtil.px2dip(this, 70.0f);
} else {
params.gravity = 85;
params.rightMargin = DensityUtil.dip2px(this, 23.0f);
params.width = DensityUtil.px2dip(this, 87.0f);
params.height = DensityUtil.px2dip(this, 87.0f);
}
params.bottomMargin = DensityUtil.dip2px(this, 57.0f);
this.mRedPacketEntry.setLayoutParams(params);
}
}
示例11: wrapChild
import android.widget.FrameLayout.LayoutParams; //导入依赖的package包/类
private View wrapChild(View child) {
if (!this.mOutlineEnabled || (child instanceof OutlineContainer)) {
return child;
}
View out = new OutlineContainer(getContext());
out.setLayoutParams(generateDefaultLayoutParams());
child.setLayoutParams(new LayoutParams(-1, -1));
out.addView(child);
return out;
}
示例12: layout
import android.widget.FrameLayout.LayoutParams; //导入依赖的package包/类
private void layout() {
int drawLocationY;
int drawLocationX;
int size;
int width;
int height;
size = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
SelectionPopupImpl.this.mView.measure(size, size);
height = SelectionPopupImpl.this.mView.getMeasuredHeight();
width = SelectionPopupImpl.this.mView.getMeasuredWidth();
drawLocationX = Math.min(SelectionPopupImpl.this.mScreenWidth - width, Math.max(0, (this.mSelectionLeft + ((this.mSelectionRight - this.mSelectionLeft) / 2)) - (width / 2)));
drawLocationY = this.mSelectionTop - height >= 0 ? this.mSelectionTop - height : (this.mSelectionBottom + height) + this.mHandleLongerAxis >= SelectionPopupImpl.this.mScreenHeight ? this.mHandleLongerAxis > 0 ? this.mSelectionBottom - height : ((this.mSelectionBottom + this.mSelectionTop) / 2) - (height / 2) : this.mSelectionBottom + this.mHandleLongerAxis;
LayoutParams layoutParams = (LayoutParams) SelectionPopupImpl.this.mView.getLayoutParams();
layoutParams.leftMargin = drawLocationX;
layoutParams.topMargin = drawLocationY;
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
SelectionPopupImpl.this.mView.requestLayout();
}
示例13: addContentView
import android.widget.FrameLayout.LayoutParams; //导入依赖的package包/类
/**
* Inflates the view, which is associated with a tab, and adds it to the view hierarchy.
*
* @param tabItem
* The tab item, which corresponds to the tab, whose associated view should be inflated,
* as an instance of the class {@link TabItem}. The tab item may not be null
*/
private void addContentView(@NonNull final TabItem tabItem) {
PhoneTabViewHolder viewHolder = (PhoneTabViewHolder) tabItem.getViewHolder();
View view = viewHolder.content;
Tab tab = tabItem.getTab();
if (view == null) {
ViewGroup parent = viewHolder.contentContainer;
Pair<View, ?> pair = tabViewRecycler.inflate(tab, parent);
view = pair.first;
LayoutParams layoutParams =
new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
Rect padding = getPadding();
layoutParams.setMargins(padding.left, padding.top, padding.right, padding.bottom);
parent.addView(view, 0, layoutParams);
viewHolder.content = view;
} else {
tabViewRecycler.getAdapter().onShowView(getModel().getContext(), view, tab, false);
}
viewHolder.previewImageView.setVisibility(View.GONE);
viewHolder.previewImageView.setImageBitmap(null);
viewHolder.borderView.setVisibility(View.GONE);
}
示例14: onShowTabView
import android.widget.FrameLayout.LayoutParams; //导入依赖的package包/类
@Override
protected final void onShowTabView(@NonNull final View view, @NonNull final TabItem tabItem,
@NonNull final Integer... params) {
LayoutParams layoutParams =
new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
int borderMargin = -(tabInset + tabBorderWidth);
int bottomMargin = params.length > 0 && params[0] != -1 ? params[0] : borderMargin;
layoutParams.leftMargin = borderMargin;
layoutParams.topMargin = -(tabInset + tabTitleContainerHeight);
layoutParams.rightMargin = borderMargin;
layoutParams.bottomMargin = bottomMargin;
view.setLayoutParams(layoutParams);
adaptContentBackgroundColor(tabItem);
adaptBackgroundVisibility(tabItem);
if (!getModel().isSwitcherShown()) {
addContentView(tabItem);
} else {
renderPreview(tabItem);
}
}
示例15: init
import android.widget.FrameLayout.LayoutParams; //导入依赖的package包/类
private void init() {
if (!(getLayoutParams() instanceof LayoutParams)) {
LayoutParams layoutParams =
new LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
Gravity.RIGHT | Gravity.TOP);
setLayoutParams(layoutParams);
}
// set default font
setTextColor(Color.WHITE);
setTypeface(Typeface.DEFAULT_BOLD);
setTextSize(TypedValue.COMPLEX_UNIT_SP, 11);
setPadding(dip2Px(5), dip2Px(1), dip2Px(5), dip2Px(1));
// set default background
setBackground(9, Color.parseColor("#d3321b"));
setGravity(Gravity.CENTER);
// default values
setHideOnNull(true);
setBadgeCount(0);
}