本文整理匯總了Java中android.view.Gravity.BOTTOM屬性的典型用法代碼示例。如果您正苦於以下問題:Java Gravity.BOTTOM屬性的具體用法?Java Gravity.BOTTOM怎麽用?Java Gravity.BOTTOM使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.view.Gravity
的用法示例。
在下文中一共展示了Gravity.BOTTOM屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findSnapView
@Override public View findSnapView(RecyclerView.LayoutManager layoutManager) {
if (layoutManager instanceof LinearLayoutManager) {
switch (mGravity) {
case Gravity.START:
return findStartView(layoutManager, getHorizontalHelper(layoutManager));
case Gravity.TOP:
return findStartView(layoutManager, getVerticalHelper(layoutManager));
case Gravity.END:
return findEndView(layoutManager, getHorizontalHelper(layoutManager));
case Gravity.BOTTOM:
return findEndView(layoutManager, getVerticalHelper(layoutManager));
}
}
return super.findSnapView(layoutManager);
}
示例2: initWindowParameter
private WindowManager.LayoutParams initWindowParameter() {
mWindowParam = new WindowManager.LayoutParams();
mWindowParam.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
mWindowParam.format = 1;
mWindowParam.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
mWindowParam.flags = mWindowParam.flags | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
mWindowParam.flags = mWindowParam.flags | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
mWindowParam.alpha = 1.0f;
mWindowParam.gravity = Gravity.BOTTOM | Gravity.RIGHT;
mWindowParam.x = 0;
mWindowParam.y = 0;
mWindowParam.width = mWindowWidth;
mWindowParam.height = mWindowHeight;
return mWindowParam;
}
示例3: setWindowParams
private void setWindowParams(int x, int y) {
// 建立item的縮略圖
windowParams = new WindowManager.LayoutParams();
windowParams.gravity = Gravity.BOTTOM | Gravity.RIGHT;// 這個必須加
// 得到preview左上角相對於屏幕的坐標
windowParams.x = x;
windowParams.y = y;
// 設置寬和高
windowParams.width = 80;
windowParams.height = 50;
windowParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
windowParams.format = PixelFormat.TRANSLUCENT;
windowParams.windowAnimations = 0;
}
示例4: HTViewPagerWithIndicator
public HTViewPagerWithIndicator(Context context, AttributeSet attrs) {
super(context, attrs);
// 添加SlidingTabLayout
readStyleParameters(attrs);
ViewPager.LayoutParams lp = new ViewPager.LayoutParams();
lp.height = ViewPager.LayoutParams.WRAP_CONTENT;
lp.width = ViewPager.LayoutParams.MATCH_PARENT;
lp.gravity = mSlidingTabLayoutGravity == 0 ? Gravity.TOP : Gravity.BOTTOM;
mSlidingTabLayout = new SlidingTabLayout(getContext(), attrs);
mDataSetObserver = new DataSetObserver() {
@Override
public void onChanged() {
super.onChanged();
mSlidingTabLayout.notifyDataSetChanged();
}
@Override
public void onInvalidated() {
super.onInvalidated();
}
};
addView(mSlidingTabLayout, -1, lp);
}
示例5: findSnapView
@Override
public View findSnapView(RecyclerView.LayoutManager layoutManager) {
View snapView = null;
if (layoutManager instanceof LinearLayoutManager) {
switch (mGravity) {
case Gravity.START:
snapView = findStartView(layoutManager, getHorizontalHelper(layoutManager));
break;
case Gravity.END:
snapView = findEndView(layoutManager, getHorizontalHelper(layoutManager));
break;
case Gravity.TOP:
snapView = findStartView(layoutManager, getVerticalHelper(layoutManager));
break;
case Gravity.BOTTOM:
snapView = findEndView(layoutManager, getVerticalHelper(layoutManager));
break;
}
}
mSnapping = snapView != null;
return snapView;
}
示例6: onStart
@Override
public void onStart() {
super.onStart();
Window window = getDialog().getWindow();
if (window != null) {
WindowManager.LayoutParams params = window.getAttributes();
params.gravity = Gravity.BOTTOM;
params.width = WindowManager.LayoutParams.MATCH_PARENT;
window.setAttributes(params);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
}
示例7: showCart
private void showCart(View view) {
if(shopCart!=null && shopCart.getShoppingAccount()>0){
ShopCartDialog dialog = new ShopCartDialog(this,shopCart,R.style.cartdialog);
Window window = dialog.getWindow();
dialog.setShopCartDialogImp(this);
dialog.setCanceledOnTouchOutside(true);
dialog.setCancelable(true);
dialog.show();
WindowManager.LayoutParams params = window.getAttributes();
params.width = WindowManager.LayoutParams.MATCH_PARENT;
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
params.gravity = Gravity.BOTTOM;
params.dimAmount =0.5f;
window.setAttributes(params);
}
}
示例8: getItemViewType
@Override public int getItemViewType(int position) {
Snap snap = mSnaps.get(position);
switch (snap.getGravity()) {
case Gravity.CENTER_VERTICAL:
return VERTICAL;
case Gravity.CENTER_HORIZONTAL:
return HORIZONTAL;
case Gravity.START:
return HORIZONTAL;
case Gravity.TOP:
return VERTICAL;
case Gravity.END:
return HORIZONTAL;
case Gravity.BOTTOM:
return VERTICAL;
}
return HORIZONTAL;
}
示例9: initViews
private void initViews() {
//initialize the viewpager
mViewPager = new ViewPager(mContext);
ViewPager.LayoutParams lp = new ViewPager.LayoutParams();
lp.width = ViewPager.LayoutParams.MATCH_PARENT;
lp.height = ViewPager.LayoutParams.MATCH_PARENT;
mViewPager.setLayoutParams(lp);
//initialize the indicator
mIndicator = new ViewPagerIndicator(mContext);
LayoutParams indicatorlp = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
indicatorlp.gravity = Gravity.BOTTOM | Gravity.CENTER;
indicatorlp.bottomMargin = 20;
mIndicator.setLayoutParams(indicatorlp);
}
示例10: addDrag
public void addDrag(DragEdge dragEdge, View child, ViewGroup.LayoutParams params) {
if (child == null) return;
if (params == null) {
params = generateDefaultLayoutParams();
}
if (!checkLayoutParams(params)) {
params = generateLayoutParams(params);
}
int gravity = -1;
switch (dragEdge) {
case Left:
gravity = Gravity.LEFT;
break;
case Right:
gravity = Gravity.RIGHT;
break;
case Top:
gravity = Gravity.TOP;
break;
case Bottom:
gravity = Gravity.BOTTOM;
break;
}
if (params instanceof LayoutParams) {
((LayoutParams) params).gravity = gravity;
}
addView(child, 0, params);
}
示例11: getTextView
/**
* 根據位置獲取TextView
*
* @param gravity 參考{@link Gravity}
* @return
*/
public TextView getTextView(int gravity) {
if (gravity == Gravity.LEFT || gravity == Gravity.START) {
return mLeftTv;
} else if (gravity == (Gravity.CENTER | Gravity.TOP)) {
return mTitleMain;
} else if (gravity == (Gravity.CENTER | Gravity.BOTTOM)) {
return mTitleSub;
} else if (gravity == Gravity.END || gravity == Gravity.RIGHT) {
return mRightTv;
}
return mTitleMain;
}
示例12: getSnappedPosition
int getSnappedPosition(RecyclerView recyclerView) {
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) {
if (gravity == Gravity.START || gravity == Gravity.TOP) {
return ((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition();
} else if (gravity == Gravity.END || gravity == Gravity.BOTTOM) {
return ((LinearLayoutManager) layoutManager).findLastCompletelyVisibleItemPosition();
}
}
return RecyclerView.NO_POSITION;
}
示例13: initVideoView
private void initVideoView(Context context) {
mAppContext = context.getApplicationContext();
mSettings = new Settings(mAppContext);
initBackground();
initRenders();
addHttpHeader();
mVideoWidth = 0;
mVideoHeight = 0;
setFocusable(true);
setFocusableInTouchMode(true);
requestFocus();
mCurrentState = STATE_IDLE;
mTargetState = STATE_IDLE;
subtitleDisplay = new TextView(context);
subtitleDisplay.setTextSize(24);
subtitleDisplay.setGravity(Gravity.CENTER);
LayoutParams layoutParams_txt = new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT,
Gravity.BOTTOM);
addView(subtitleDisplay, layoutParams_txt);
}
示例14: onDraw
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (buttonDrawable != null) {
buttonDrawable.setState(getDrawableState());
final int verticalGravity = getGravity()
& Gravity.VERTICAL_GRAVITY_MASK;
final int height = buttonDrawable.getIntrinsicHeight();
int y = 0;
switch (verticalGravity) {
case Gravity.BOTTOM:
y = getHeight() - height;
break;
case Gravity.CENTER_VERTICAL:
y = (getHeight() - height) / 2;
break;
}
int buttonWidth = buttonDrawable.getIntrinsicWidth();
int buttonLeft = (getWidth() - buttonWidth) / 2;
buttonDrawable.setBounds(buttonLeft, y, buttonLeft + buttonWidth, y
+ height);
buttonDrawable.draw(canvas);
}
}
示例15: onCreateView
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//設置無標題
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
//設置從底部彈出
Window window = getDialog().getWindow();
WindowManager.LayoutParams params = window.getAttributes();
params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
window.requestFeature(Window.FEATURE_NO_TITLE);
window.setAttributes(params);
return null;
}