本文整理匯總了Java中android.view.Gravity.TOP屬性的典型用法代碼示例。如果您正苦於以下問題:Java Gravity.TOP屬性的具體用法?Java Gravity.TOP怎麽用?Java Gravity.TOP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.view.Gravity
的用法示例。
在下文中一共展示了Gravity.TOP屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initCross
private void initCross(Context context) {
ImageView cross = new ImageView(context);
LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
layoutParams.gravity = Gravity.TOP | Gravity.END;
cross.setLayoutParams(layoutParams);
cross.setImageDrawable(completeIcon);
this.addView(cross);
cross.setOnClickListener(new OnClickListener() {
public final void onClick(View it) {
if (TutorialLayout.this.tutorialListener != null) {
TutorialLayout.this.tutorialListener.onCompleteAll();
}
}
});
}
示例2: setupStatusBarView
public static void setupStatusBarView(Activity activity, ViewGroup decorViewGroup, boolean on, int colorRes) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window win = activity.getWindow();
setTranslucentStatus(win, on);
View mStatusBarTintView = new View(activity);
int mStatusBarHeight = 0;
int resourceId = activity.getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
mStatusBarHeight = activity.getResources().getDimensionPixelSize(resourceId);
}
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, mStatusBarHeight);
params.gravity = Gravity.TOP;
mStatusBarTintView.setLayoutParams(params);
mStatusBarTintView.setBackgroundResource(colorRes);
mStatusBarTintView.setVisibility(View.VISIBLE);
decorViewGroup.addView(mStatusBarTintView);
}
}
示例3: init
public static void init(Context context) {
sWindowManager = (WindowManager) context.getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
sLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
VERSION.SDK_INT >= VERSION_CODES.M ? LayoutParams.TYPE_SYSTEM_ALERT : LayoutParams.TYPE_TOAST,
0x18, PixelFormat.TRANSLUCENT);
sLayoutParams.gravity = Gravity.TOP | Gravity.LEFT;
sView = LayoutInflater.from(context.getApplicationContext()).inflate(R.layout.view_tracker_window, null);
}
示例4: onLayout
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
final View child = getChildAt(0);
if (child == null) {
return;
}
if (mGravity == Gravity.TOP) {
child.layout(0, 0, getMeasuredWidth(), child.getMeasuredHeight());
} else {
child.layout(0, getMeasuredHeight() - child.getMeasuredHeight(), getMeasuredWidth(), getMeasuredHeight());
}
}
示例5: onClick
@Override
public void onClick(final View v) {
if (currentLookForWid.getText().equals(" ")) {
v.startAnimation(notItAnim);
return;
}
String symv = (String)v.getTag();
TextView wid2 = activeSyms.get(current);
if (wid2==null) return;
String symw = (String)wid2.getTag();
if (symv.equals(symw)) {
Log.d("Doda", "Found " + symv.codePointAt(0));
v.setAlpha(.6f);
v.startAnimation(wasItAnim);
final ImageView blow = new ImageView(this);
blow.setBackgroundResource(R.drawable.explosion);
Point location = symPoints.get((TextView)v);
float fac = 1.25f;
score += Math.max(100, 5000 - (System.currentTimeMillis() - findTime)) * (backgroundImage?1.5:1);
int msize = spToPx((int)(mMode.getMaxIconSize(bsize)*fac));
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(msize, msize);
lp.setMargins(location.x - (int)(mMode.getMaxIconSize(bsize)*fac/2), location.y - (int)(mMode.getMaxIconSize(bsize)*fac/2), 0, 0);
lp.gravity = Gravity.START | Gravity.TOP;
blow.setLayoutParams(lp);
mSoundEffects.playPlode();
v.clearAnimation();
mMainScreen.removeView(v);
activeSyms.set(current, null);
mMainScreen.addView(blow);
AnimationDrawable ad = ((AnimationDrawable) blow.getBackground());
int time = ad.getNumberOfFrames() * ad.getDuration(0);
ad.start();
showNext(false);
mMainScreen.postDelayed(new Runnable() {
@Override
public void run() {
mMainScreen.removeView(blow);
}
}, time + 20);
} else {
v.startAnimation(notItAnim);
if (mMode.isTimed()) {
startTime -= 5000;
showMessage(getString(R.string.miss_penalty));
}
}
}
示例6: setMsgMargin
/**
* 設置提示紅點偏移,注意
* 1.控件為固定高度:參照點為tab內容的右上角
* 2.控件高度不固定(WRAP_CONTENT):參照點為tab內容的右上角,此時高度已是紅點的最高顯示範圍,所以這時bottomPadding其實就是topPadding
*/
public void setMsgMargin(int position, float leftPadding, float bottomPadding) {
if (position >= mTabCount) {
position = mTabCount - 1;
}
View tabView = mTabsContainer.getChildAt(position);
MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
if (tipView != null) {
TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
mTextPaint.setTextSize(mTextsize);
float textWidth = mTextPaint.measureText(tv_tab_title.getText().toString());
float textHeight = mTextPaint.descent() - mTextPaint.ascent();
MarginLayoutParams lp = (MarginLayoutParams) tipView.getLayoutParams();
float iconH = mIconHeight;
float margin = 0;
if (mIconVisible) {
if (iconH <= 0) {
iconH = mContext.getResources().getDrawable(mTabEntitys.get(position).getTabSelectedIcon()).getIntrinsicHeight();
}
margin = mIconMargin;
}
if (mIconGravity == Gravity.TOP || mIconGravity == Gravity.BOTTOM) {
lp.leftMargin = dp2px(leftPadding);
lp.topMargin = mHeight > 0 ? (int) (mHeight - textHeight - iconH - margin) / 2 - dp2px(bottomPadding) : dp2px(bottomPadding);
} else {
lp.leftMargin = dp2px(leftPadding);
lp.topMargin = mHeight > 0 ? (int) (mHeight - Math.max(textHeight, iconH)) / 2 - dp2px(bottomPadding) : dp2px(bottomPadding);
}
tipView.setLayoutParams(lp);
}
}
示例7: init
public static void init(final Context context){
sWindowManager = (WindowManager) context.getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
sWindowLayoutParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
Build.VERSION.SDK_INT > Build.VERSION_CODES.N?
WindowManager.LayoutParams.TYPE_PHONE: WindowManager.LayoutParams.TYPE_TOAST,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
PixelFormat.TRANSLUCENT
);
sWindowLayoutParams.gravity = Gravity.TOP + Gravity.RIGHT;
sView = LayoutInflater.from(context).inflate(R.layout.layout_floating_window,null);
}
示例8: setTextImage
/**
* 設置TextViewImage,方向個數必須和res個數相同
*
* @param viewId View ID
* @param gravity {@link Gravity#START}|{@link Gravity#TOP}|{@link Gravity#END}|{@link Gravity#BOTTOM}
* @param resId 資源ID
*/
public void setTextImage(@IdRes int viewId, int gravity, @DrawableRes int... resId) {
int index = 0;
// 初始化Drawable
int length = resId.length;
Drawable[] initDrawables = new Drawable[length];
for (int i = 0; i < length; i++) {
Drawable drawable = ContextCompat.getDrawable(getContext(), resId[i]);
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
initDrawables[i] = drawable;
}
// 設置Drawable
Drawable[] setDrawables = new Drawable[4];
if ((gravity & Gravity.START) == Gravity.START) {
setDrawables[0] = initDrawables[index++];
}
if ((gravity & Gravity.TOP) == Gravity.TOP) {
setDrawables[1] = initDrawables[index++];
}
if ((gravity & Gravity.END) == Gravity.END) {
setDrawables[2] = initDrawables[index++];
}
if ((gravity & Gravity.BOTTOM) == Gravity.BOTTOM) {
setDrawables[3] = initDrawables[index];
}
TextView tv = getView(viewId);
tv.setCompoundDrawables(setDrawables[0], setDrawables[1], setDrawables[2], setDrawables[3]);
}
示例9: createPopupLayout
private WindowManager.LayoutParams createPopupLayout(IBinder token) {
WindowManager.LayoutParams p = new WindowManager.LayoutParams();
p.gravity = Gravity.START | Gravity.TOP;
p.width = ViewGroup.LayoutParams.MATCH_PARENT;
p.height = ViewGroup.LayoutParams.MATCH_PARENT;
p.format = PixelFormat.TRANSLUCENT;
p.flags = computeFlags(p.flags);
p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
p.token = token;
p.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN;
p.setTitle("DiscreteSeekBar Indicator:" + Integer.toHexString(hashCode()));
return p;
}
示例10: getSnappedPosition
int getSnappedPosition(RecyclerView recyclerView) {
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) {
if (mGravity == Gravity.START || mGravity == Gravity.TOP) {
return ((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition();
} else if (mGravity == Gravity.END || mGravity == Gravity.BOTTOM) {
return ((LinearLayoutManager) layoutManager).findLastCompletelyVisibleItemPosition();
}
}
return RecyclerView.NO_POSITION;
}
示例11: setupStatusBarView
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);
}
示例12: initWindowParams
private void initWindowParams() {
mWindowManager = (WindowManager) getApplication().getSystemService(WINDOW_SERVICE);
mWindowParams = new WindowManager.LayoutParams();
mWindowParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
mWindowParams.format = PixelFormat.TRANSLUCENT;
mWindowParams.flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
mWindowParams.gravity = Gravity.START | Gravity.TOP;
mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
}
示例13: show
public void show() {
if (mState >= DESTROYING) {
return;
}
if (mState == UNCREATED) {
create();
}
if (!mOutsideTouchable) {
addMask();
}
if (mState == CREATED) {
WindowManager windowManager = (WindowManager) mContext.getSystemService(WINDOW_SERVICE);
WindowManager.LayoutParams windowParams = new WindowManager.LayoutParams();
windowParams.gravity = Gravity.TOP | Gravity.LEFT;
windowParams.x = 0;
windowParams.y = 0;
windowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
windowParams.width = WindowManager.LayoutParams.MATCH_PARENT;
windowParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
windowParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
windowParams.format = PixelFormat.TRANSLUCENT;
windowParams.windowAnimations = 0;
windowManager.addView(mRootLayout, windowParams);
}
mState = VISIBLE;
mRootLayout.setVisibility(View.VISIBLE);
mRootLayout.show();
startCountDown(mDuration);
}
示例14: getYBasedOnGravity
private int getYBasedOnGravity(int height){
int [] pos = new int[2];
mHighlightedView.getLocationInWindow(pos);
int y = pos[1];
if((mPointer.mGravity & Gravity.BOTTOM) == Gravity.BOTTOM){
return y+mHighlightedView.getHeight()-height;
} else if ((mPointer.mGravity & Gravity.TOP) == Gravity.TOP) {
return y;
}else { // this is center
return y+mHighlightedView.getHeight()/2-height/2;
}
}
示例15: UserCell
public UserCell(Context context, int padding, int checkbox, boolean admin) {
super(context);
avatarDrawable = new AvatarDrawable();
avatarImageView = new BackupImageView(context);
avatarImageView.setRoundRadius(AndroidUtilities.dp(24));
int avLeftMargin=LocaleController.isRTL ? 0 : 0 + padding;
int avRightMargin=LocaleController.isRTL ? 0 + padding : 0;
int gravity=(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
addView(avatarImageView, LayoutHelper.createFrame(48, 48, gravity, avLeftMargin, 8, avRightMargin, 0));
mutualView=new ImageView(context);
mutualView.setVisibility(GONE);
addView(mutualView, LayoutHelper.createFrame(22, 22, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL,
LocaleController.isRTL ? 16 : 0
,
0
,
/*LocaleController.isRTL ?
AndroidUtilities.dp(65f) + avLeftMargin
: avLeftMargin - AndroidUtilities.dp(25f)*/
LocaleController.isRTL ? 0 : 16
, 0));
mutualView.setImageResource(R.drawable.party);
mutualView.setColorFilter(SkinMan.currentSkin.actionbarColor());
nameTextView = new SimpleTextView(context);
nameTextView.setTextColor(0xff212121);
nameTextView.setTextSize(17);
nameTextView.setTypeface(FontManager.instance().getTypeface());
nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 28 + (checkbox == 2 ? 18 : 0) : (68 + padding), 11.5f, LocaleController.isRTL ? (68 + padding) : 28 + (checkbox == 2 ? 18 : 0), 0));
statusTextView = new SimpleTextView(context);
statusTextView.setTextSize(14);
statusTextView.setTypeface(FontManager.instance().getTypeface());
statusTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
addView(statusTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 28 : (68 + padding), 34.5f, LocaleController.isRTL ? (68 + padding) : 28, 0));
imageView = new ImageView(context);
imageView.setScaleType(ImageView.ScaleType.CENTER);
imageView.setVisibility(GONE);
addView(imageView, LayoutHelper.createFrame(LayoutParams.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 0 : 16, 0, LocaleController.isRTL ? 16 : 0, 0));
if (checkbox == 2) {
checkBoxBig = new CheckBoxSquare(context);
addView(checkBoxBig, LayoutHelper.createFrame(18, 18, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 19 : 0, 0, LocaleController.isRTL ? 0 : 19, 0));
} else if (checkbox == 1) {
checkBox = new CheckBox(context, R.drawable.round_check2);
checkBox.setVisibility(INVISIBLE);
addView(checkBox, LayoutHelper.createFrame(22, 22, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 37 + padding, 38, LocaleController.isRTL ? 37 + padding : 0, 0));
}
if (admin) {
adminImage = new ImageView(context);
addView(adminImage, LayoutHelper.createFrame(16, 16, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, LocaleController.isRTL ? 24 : 0, 13.5f, LocaleController.isRTL ? 0 : 24, 0));
}
statusOnlineColor= SkinMan.currentSkin.actionbarColor();
}