本文整理匯總了Java中android.view.Gravity.START屬性的典型用法代碼示例。如果您正苦於以下問題:Java Gravity.START屬性的具體用法?Java Gravity.START怎麽用?Java Gravity.START使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.view.Gravity
的用法示例。
在下文中一共展示了Gravity.START屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addWindow
static void addWindow(Application app) {
activityLifecycleObservable = new ActivityLifecycleObservable();
activityTaskView = new ActivityTaskView(app);
activityTaskView.setObservable(activityLifecycleObservable);
qhandler = new QueueHandler();
WindowManager windowManager = (WindowManager) app.getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams params = new WindowManager.LayoutParams();
params.type = WindowManager.LayoutParams.TYPE_PHONE;
params.format = PixelFormat.RGBA_8888;
params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
params.width = WindowManager.LayoutParams.WRAP_CONTENT;
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
params.gravity = Gravity.START | Gravity.TOP;
params.x = 0;
params.y = app.getResources().getDisplayMetrics().heightPixels;
windowManager.addView(activityTaskView, params);
app.registerActivityLifecycleCallbacks(activityLifecycleCallbacks);
}
示例2: calculateDistanceToFinalSnap
public int[] calculateDistanceToFinalSnap(@NonNull RecyclerView.LayoutManager layoutManager,
@NonNull View targetView) {
int[] out = new int[2];
if (layoutManager.canScrollHorizontally()) {
if (gravity == Gravity.START) {
out[0] = distanceToStart(targetView, getHorizontalHelper(layoutManager), false);
} else { // END
out[0] = distanceToEnd(targetView, getHorizontalHelper(layoutManager), false);
}
} else {
out[0] = 0;
}
if (layoutManager.canScrollVertically()) {
if (gravity == Gravity.TOP) {
out[1] = distanceToStart(targetView, getVerticalHelper(layoutManager), false);
} else { // BOTTOM
out[1] = distanceToEnd(targetView, getVerticalHelper(layoutManager), false);
}
} else {
out[1] = 0;
}
return out;
}
示例3: setGravity
/**
* Sets the horizontal alignment of the text and the
* vertical gravity that will be used when there is extra space
* in the TextView beyond what is required for the text itself.
*
* @see android.view.Gravity
*/
public boolean setGravity(int gravity) {
if ((gravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) {
gravity |= Gravity.START;
}
if ((gravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) {
gravity |= Gravity.TOP;
}
boolean newLayout = false;
if ((gravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) !=
(mGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK)) {
newLayout = true;
}
if (gravity != mGravity) {
newLayout = true;
}
mGravity = gravity;
return newLayout;
}
示例4: setButtonLayout
private void setButtonLayout(View buttonView, CFAlertActionButton actionButton) {
LinearLayout.LayoutParams buttonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
;
switch (actionButton.alignment) {
case JUSTIFIED:
buttonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
break;
case START:
buttonParams.gravity = Gravity.START;
break;
case CENTER:
buttonParams.gravity = Gravity.CENTER;
break;
case END:
buttonParams.gravity = Gravity.END;
break;
}
buttonView.setLayoutParams(buttonParams);
int padding = ((int) buttonView.getResources().getDimension(R.dimen.cfdialog_button_padding));
buttonView.setPadding(padding, padding, padding, padding);
}
示例5: 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;
}
示例6: 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;
}
示例7: attachToRecyclerView
@Override
public void attachToRecyclerView(@Nullable RecyclerView recyclerView)
throws IllegalStateException {
if (recyclerView != null) {
if (mGravity == Gravity.START || mGravity == Gravity.END) {
mIsRtlHorizontal = (recyclerView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
// = recyclerView.getContext().getResources().getBoolean(R.bool.is_rtl);
}
if (mSnapListener != null) {
recyclerView.addOnScrollListener(mScrollListener);
}
}
super.attachToRecyclerView(recyclerView);
}
示例8: appleStyleAfterCreated
/**
* Process view after created.
*
* @param editText
*/
protected void appleStyleAfterCreated(WXEditText editText) {
String alignStr = (String) getDomObject().getStyles().get(Constants.Name.TEXT_ALIGN);
int textAlign = getTextAlign(alignStr);
if (textAlign <= 0) {
textAlign = Gravity.START;
}
editText.setGravity(textAlign | getVerticalGravity());
int colorInt = WXResourceUtils.getColor("#999999");
if (colorInt != Integer.MIN_VALUE) {
editText.setHintTextColor(colorInt);
}
editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, WXStyle.getFontSize(getDomObject().getStyles(),getInstance().getInstanceViewPortWidth()));
}
示例9: setIndicatorGravity
public BannerView setIndicatorGravity(int gravity) {
if (mGravity != gravity) {
if ((gravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) {
gravity |= Gravity.START;
}
if ((gravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) {
gravity |= Gravity.TOP;
}
mGravity = gravity;
}
return this;
}
示例10: attachToRecyclerView
public void attachToRecyclerView(@NonNull RecyclerView recyclerView) {
if (recyclerView != null) {
if ((gravity == Gravity.START || gravity == Gravity.END)
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
isRtlHorizontal
= recyclerView.getContext().getResources().getConfiguration()
.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
if (listener != null) {
recyclerView.addOnScrollListener(mScrollListener);
}
}
}
示例11: 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;
}
示例12: init
private void init(Context context) {
inflate(context, R.layout.detail_similar_movies_wrapper, this);
ButterKnife.bind(this);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
recyclerView.setLayoutManager(linearLayoutManager);
SnapHelper snapHelper = new GravitySnapHelper(Gravity.START);
snapHelper.attachToRecyclerView(recyclerView);
recyclerView.setHasFixedSize(true);
recyclerView.setMotionEventSplittingEnabled(false);
recyclerView.setNestedScrollingEnabled(false);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(adapter);
}
示例13: 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);
}
示例14: setupTransitions
/**
* Setup fragment transitions
*/
public void setupTransitions() {
SidePropagation propagateBottom = new SidePropagation();
propagateBottom.setSide(Gravity.BOTTOM);
propagateBottom.setPropagationSpeed(2);
SidePropagation propagateTop = new SidePropagation();
propagateTop.setSide(Gravity.TOP);
propagateTop.setPropagationSpeed(2);
// Transition used for replacement fragments
mNewEnterTransition = new Slide(Gravity.END);
mNewEnterTransition.setPropagation(propagateBottom);
mNewEnterTransition.setStartDelay(100);
mNewExitTransition = new Slide(Gravity.END);
mNewExitTransition.setPropagation(propagateBottom);
mNewExitTransition.setStartDelay(0);
// Transition used for main menu entering and exiting
mMainExitTransition = new Slide(Gravity.START);
mMainExitTransition.setPropagation(propagateTop);
mMainExitTransition.setStartDelay(0);
// Transition used for main menu reentering
mMainReenterTransition = new Slide(Gravity.START);
mMainReenterTransition.setPropagation(propagateTop);
mMainReenterTransition.setStartDelay(200);
}
示例15: 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;
}