本文整理匯總了Java中android.view.Gravity.END屬性的典型用法代碼示例。如果您正苦於以下問題:Java Gravity.END屬性的具體用法?Java Gravity.END怎麽用?Java Gravity.END使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.view.Gravity
的用法示例。
在下文中一共展示了Gravity.END屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findSnapView
public View findSnapView(RecyclerView.LayoutManager layoutManager) {
View snapView = null;
if (layoutManager instanceof LinearLayoutManager) {
switch (gravity) {
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;
}
}
snapping = snapView != null;
return snapView;
}
示例2: onTargetAlignmentChanged
@OnCheckedChanged({ R.id.target_align_start, R.id.target_align_center, R.id.target_align_end })
void onTargetAlignmentChanged(RadioButton button, boolean isChecked) {
if (isChecked) {
int alignment = Gravity.NO_GRAVITY;
switch (button.getId()) {
case R.id.target_align_start:
alignment = Gravity.START;
break;
case R.id.target_align_center:
alignment = Gravity.CENTER_HORIZONTAL;
break;
case R.id.target_align_end:
alignment = Gravity.END;
break;
}
onUpdateListener.updateTargetTextAlignment(alignment);
}
}
示例3: 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;
}
示例4: getGravity
private int getGravity(String gravity) {
switch (gravity) {
case "CENTER":
return Gravity.CENTER;
case "CENTER_VERTICAL":
return Gravity.CENTER_VERTICAL;
case "TOP":
return Gravity.TOP;
case "LEFT":
return Gravity.LEFT;
case "RIGHT":
return Gravity.RIGHT;
case "BOTTOM":
return Gravity.BOTTOM;
case "START":
return Gravity.START;
case "END":
return Gravity.END;
default:
return Gravity.CENTER_VERTICAL;
}
}
開發者ID:cesardeazevedo,項目名稱:react-native-collapsing-toolbar,代碼行數:22,代碼來源:CollapsingToolbarLayoutManager.java
示例5: positionItems
/**
* Positions the children at the "correct" positions
*/
private void positionItems() {
final int childCount = getChildCount();
int left = getPaddingStart();
if (getFixedGravity() == Gravity.CENTER) {
left += (getContentWidth() - childCount * (itemSize + minItemSpacing) + minItemSpacing) / 2;
} else if (getFixedGravity() == Gravity.END) {
left += (getContentWidth() - childCount * (itemSize + minItemSpacing) + minItemSpacing);
}
for (int i = 0; i < childCount; i++) {
final View child = getChildAt(i);
final int childWidth = child.getMeasuredWidth();
final int childHeight = child.getMeasuredHeight();
final int top = (getHeight() - childHeight) / 2;
final int contentWidth = getContentWidth();
final int itemSpacing = getItemSpacing(childCount, contentWidth, childWidth);
child.layout(left, top, left + childWidth, top + childHeight);
if (!isLastChild(i)) {
left += childWidth + itemSpacing;
}
}
}
示例6: 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;
}
示例7: getTextAlign
private int getTextAlign(String textAlign) {
int align = Gravity.START;
if (TextUtils.isEmpty(textAlign)) {
return align;
}
if (textAlign.equals(Constants.Value.LEFT)) {
align = Gravity.START;
} else if (textAlign.equals(Constants.Value.CENTER)) {
align = Gravity.CENTER;
} else if (textAlign.equals(Constants.Value.RIGHT)) {
align = Gravity.END;
}
return align;
}
示例8: onAction
@Override
public void onAction(View actionView, final int position) {
final Song song = mAdapter.getItem(position);
PopupMenu actionMenu = new PopupMenu(this, actionView, Gravity.END | Gravity.BOTTOM);
actionMenu.inflate(R.menu.music_action);
actionMenu.getMenu().findItem(R.id.menu_item_delete).setVisible(!isFolder);
actionMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_item_add_to_play_list:
new AddToPlayListDialogFragment()
.setCallback(new AddToPlayListDialogFragment.Callback() {
@Override
public void onPlayListSelected(PlayList playList) {
if (playList.getId() == mPlayList.getId()) return;
mPresenter.addSongToPlayList(song, playList);
}
})
.show(getSupportFragmentManager().beginTransaction(), "AddToPlayList");
break;
case R.id.menu_item_delete:
mDeleteIndex = position;
mPresenter.delete(song, mPlayList);
break;
}
return true;
}
});
actionMenu.show();
}
示例9: getGravity
private ViewGroup.LayoutParams getGravity(View childView) {
FrameLayout.LayoutParams lp = (LayoutParams) childView.getLayoutParams();
if (isGravityCenter) {
lp.gravity = Gravity.CENTER;
} else if (isGravityBottom) {
if (isGravityEnd) {
lp.gravity = Gravity.BOTTOM | Gravity.END;
} else if (isGravityCenterHorizontal) {
lp.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
} else {
lp.gravity = Gravity.BOTTOM;
}
} else if (isGravityEnd) {
if (isGravityCenterVertical) {
lp.gravity = Gravity.CENTER_VERTICAL | Gravity.END;
} else {
lp.gravity = Gravity.TOP | Gravity.END;
}
} else if (isGravityTop) {
lp.gravity = Gravity.TOP;
} else if (isGravityCenterHorizontal) {
lp.gravity = Gravity.CENTER_HORIZONTAL;
} else if (isGravityCenterVertical) {
lp.gravity = Gravity.CENTER_VERTICAL;
}
return lp;
}
示例10: convertGravity
private static int convertGravity(View view, int gravity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
boolean isRtl = view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
if (gravity == Gravity.START) {
gravity = isRtl ? Gravity.RIGHT : Gravity.LEFT;
} else if (gravity == Gravity.END) {
gravity = isRtl ? Gravity.LEFT : Gravity.RIGHT;
}
}
return gravity;
}
示例11: attachToRecyclerView
@Override
public void attachToRecyclerView(@Nullable RecyclerView recyclerView)
throws IllegalStateException {
if (recyclerView != null) {
if (mGravity == Gravity.START || mGravity == Gravity.END) {
mIsRtlHorizontal
= recyclerView.getContext().getResources().getBoolean(R.bool.is_rtl);
}
if (mSnapListener != null) {
recyclerView.addOnScrollListener(mScrollListener);
}
}
super.attachToRecyclerView(recyclerView);
}
示例12: init
private void init(Context context) {
inflate(context, R.layout.detail_images_wrapper, this);
ButterKnife.bind(this);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
recyclerView.setLayoutManager(linearLayoutManager);
SnapHelper snapHelper = new GravitySnapHelper(Gravity.END);
snapHelper.attachToRecyclerView(recyclerView);
recyclerView.setHasFixedSize(true);
recyclerView.setMotionEventSplittingEnabled(false);
recyclerView.setNestedScrollingEnabled(false);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(adapter);
}
示例13: 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;
}
示例14: GravitySnapHelper
public GravitySnapHelper(int gravity, boolean enableSnapLastItem, SnapListener snapListener) {
if (gravity != Gravity.START && gravity != Gravity.END
&& gravity != Gravity.BOTTOM && gravity != Gravity.TOP) {
throw new IllegalArgumentException("Invalid gravity value. Use START " +
"| END | BOTTOM | TOP constants");
}
mSnapListener = snapListener;
mGravity = gravity;
mSnapLastItemEnabled = enableSnapLastItem;
}
示例15: calculate
public void calculate() {
for (AnimExpectation animExpectation : animExpectations) {
if (animExpectation instanceof ScaleAnimExpectation) {
final ScaleAnimExpectation expectation = (ScaleAnimExpectation) animExpectation;
expectation.setViewCalculator(viewCalculator);
final Float scaleX = expectation.getCalculatedValueScaleX(viewToMove);
if (scaleX != null) {
this.scaleX = scaleX;
}
final Float scaleY = expectation.getCalculatedValueScaleY(viewToMove);
if (scaleY != null) {
this.scaleY = scaleY;
}
final Integer gravityHorizontal = expectation.getGravityHorizontal();
if (gravityHorizontal != null) {
switch (gravityHorizontal){
case Gravity.LEFT:
case Gravity.START:
pivotX = (float)viewToMove.getLeft();
break;
case Gravity.RIGHT:
case Gravity.END:
pivotX = (float)viewToMove.getRight();
break;
case Gravity.CENTER_HORIZONTAL:
case Gravity.CENTER : pivotX = viewToMove.getLeft() + viewToMove.getWidth()/2f; break;
}
}
final Integer gravityVertical = expectation.getGravityVertical();
if (gravityVertical != null) {
switch (gravityVertical){
case Gravity.TOP : pivotY = (float)viewToMove.getTop(); break;
case Gravity.BOTTOM : pivotY = (float)viewToMove.getBottom(); break;
case Gravity.CENTER_VERTICAL:
case Gravity.CENTER : pivotY = viewToMove.getTop() + viewToMove.getHeight()/2f; break;
}
}
}
}
}