Java Code Examples for android.view.View#LAYOUT_DIRECTION_LTR
The following examples show how to use
android.view.View#LAYOUT_DIRECTION_LTR .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TriggerBackgroundView.java From science-journal with Apache License 2.0 | 6 votes |
private void init() { int backgroundColor = getResources().getColor(R.color.text_color_dark_grey); int triggerColor = getResources().getColor(R.color.trigger_fire_color); triggerPaint = new Paint(Paint.ANTI_ALIAS_FLAG); triggerPaint.setColor(triggerColor); triggerPaint.setStyle(Paint.Style.FILL); backgroundPaint = new Paint(); backgroundPaint.setColor(backgroundColor); backgroundPaint.setStyle(Paint.Style.FILL); triggerOutline = new RectF(); triggerPath = new Path(); isLtrLayout = getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_LTR; }
Example 2
Source File: DrawerLayout.java From Dashchan with Apache License 2.0 | 6 votes |
private Drawable resolveLeftShadow() { int layoutDirection = getLayoutDirection(this); // Prefer shadows defined with start/end gravity over left and right. if (layoutDirection == View.LAYOUT_DIRECTION_LTR) { if (mShadowStart != null) { // Correct drawable layout direction, if needed. mirror(mShadowStart, layoutDirection); return mShadowStart; } } else { if (mShadowEnd != null) { // Correct drawable layout direction, if needed. mirror(mShadowEnd, layoutDirection); return mShadowEnd; } } return mShadowLeft; }
Example 3
Source File: MountState.java From litho with Apache License 2.0 | 6 votes |
private static void setViewLayoutDirection(View view, ViewNodeInfo viewNodeInfo) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { return; } final int viewLayoutDirection; switch (viewNodeInfo.getLayoutDirection()) { case LTR: viewLayoutDirection = View.LAYOUT_DIRECTION_LTR; break; case RTL: viewLayoutDirection = View.LAYOUT_DIRECTION_RTL; break; default: viewLayoutDirection = View.LAYOUT_DIRECTION_INHERIT; } view.setLayoutDirection(viewLayoutDirection); }
Example 4
Source File: GestureSelectionHelper.java From FairEmail with GNU General Public License v3.0 | 5 votes |
@VisibleForTesting static boolean isPastLastItem( int top, int left, int right, @NonNull MotionEvent e, int direction) { if (direction == View.LAYOUT_DIRECTION_LTR) { return e.getX() > right && e.getY() > top; } else { return e.getX() < left && e.getY() > top; } }
Example 5
Source File: TextBadge.java From Badger with Apache License 2.0 | 5 votes |
@Override public int getLayoutDirection() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return super.getLayoutDirection(); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { return View.LAYOUT_DIRECTION_LTR; } //noinspection WrongConstant return 0; // LAYOUT_DIRECTION_LTR }
Example 6
Source File: DisplayHelper.java From AndroidBlueprints with Apache License 2.0 | 5 votes |
/** * Sets window layout rtl. */ public static void setWindowLayoutRtl(Activity activity) { if (activity.getWindow() .getDecorView() .getLayoutDirection() == View.LAYOUT_DIRECTION_LTR) { activity.getWindow() .getDecorView() .setLayoutDirection(View.LAYOUT_DIRECTION_RTL); } }
Example 7
Source File: PlaybackNotificationFactoryImpl.java From PainlessMusicPlayer with Apache License 2.0 | 5 votes |
private static void addAction3(@NonNull final Context context, @NonNull final NotificationCompat.Builder b) { final int direction = context.getResources().getInteger(R.integer.layoutDirection); switch (direction) { case View.LAYOUT_DIRECTION_RTL: addActionPrev(context, b); break; case View.LAYOUT_DIRECTION_LTR: default: addActionNext(context, b); break; } }
Example 8
Source File: DocumentsActivity.java From FireFiles with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public int getGravity() { if(Utils.hasJellyBeanMR1()){ Configuration config = getResources().getConfiguration(); if(config.getLayoutDirection() != View.LAYOUT_DIRECTION_LTR){ return Gravity.LEFT; } } return Gravity.RIGHT; }
Example 9
Source File: DocumentsActivity.java From FireFiles with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public int getGravity() { if(Utils.hasJellyBeanMR1()){ Configuration config = getResources().getConfiguration(); if(config.getLayoutDirection() != View.LAYOUT_DIRECTION_LTR){ return Gravity.LEFT; } } return Gravity.RIGHT; }
Example 10
Source File: ViewHelper.java From Cybernet-VPN with GNU General Public License v3.0 | 5 votes |
@SuppressLint("NewApi") static int getLayoutDirection(View v) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { return v.getLayoutDirection(); } return View.LAYOUT_DIRECTION_LTR; }
Example 11
Source File: PlaybackNotificationFactoryImpl.java From PainlessMusicPlayer with Apache License 2.0 | 5 votes |
private static void addAction1( @NonNull final Context context, @NonNull final NotificationCompat.Builder b) { final int direction = context.getResources().getInteger(R.integer.layoutDirection); switch (direction) { case View.LAYOUT_DIRECTION_RTL: addActionNext(context, b); break; case View.LAYOUT_DIRECTION_LTR: default: addActionPrev(context, b); break; } }
Example 12
Source File: ViewHelper.java From SwipeBack with Apache License 2.0 | 5 votes |
@SuppressWarnings("") public static int getLayoutDirection(View v) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { return v.getLayoutDirection(); } return View.LAYOUT_DIRECTION_LTR; }
Example 13
Source File: ConfigDefinition.java From Last-Launcher with GNU General Public License v3.0 | 5 votes |
public void setLayoutDirection(int layoutDirection) { if (layoutDirection == View.LAYOUT_DIRECTION_RTL) { this.layoutDirection = layoutDirection; } else { this.layoutDirection = View.LAYOUT_DIRECTION_LTR; } }
Example 14
Source File: ViewHelper.java From FlowingPager with Apache License 2.0 | 5 votes |
@SuppressLint("NewApi") static int getLayoutDirection(View v) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { return v.getLayoutDirection(); } return View.LAYOUT_DIRECTION_LTR; }
Example 15
Source File: Compat.java From ProjectX with Apache License 2.0 | 5 votes |
static int getLayoutDirection(Drawable drawable) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) return drawable.getLayoutDirection(); else if (SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) return View.LAYOUT_DIRECTION_LTR; else return 0; }
Example 16
Source File: TimeDurationPicker.java From PhoneProfilesPlus with Apache License 2.0 | 5 votes |
private void applyLeftMargin(int margin, View... targetViews) { for (View view : targetViews) { final LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) view.getLayoutParams(); boolean isLeftToRight = TextUtils.getLayoutDirectionFromLocale(Locale.getDefault())==View.LAYOUT_DIRECTION_LTR; if (isLeftToRight) params.setMargins(margin, params.topMargin, params.rightMargin, params.bottomMargin); else params.setMargins(params.leftMargin, params.topMargin, margin, params.bottomMargin); view.setLayoutParams(params); } }
Example 17
Source File: GroupSettingsCoordinatorLayoutBehavior.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
private static int getStart(@NonNull CoordinatorLayout parent, @NonNull Rect rect) { return parent.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR ? rect.left : rect.right; }
Example 18
Source File: UiUtil.java From edx-app-android with Apache License 2.0 | 4 votes |
/** * Utility method to check the screen direction * @return true if direction is LTR false else wise */ public static boolean isDirectionLeftToRight() { Configuration config = MainApplication.instance().getResources().getConfiguration(); return config.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR; }
Example 19
Source File: TimePickerClockDelegate.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
private void setAmPmStart(boolean isAmPmAtStart) { final RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mAmPmLayout.getLayoutParams(); if (params.getRule(RelativeLayout.RIGHT_OF) != 0 || params.getRule(RelativeLayout.LEFT_OF) != 0) { // Horizontal mode, with AM/PM appearing to left/right of hours and minutes. final boolean isAmPmAtLeft; if (TextUtils.getLayoutDirectionFromLocale(mLocale) == View.LAYOUT_DIRECTION_LTR) { isAmPmAtLeft = isAmPmAtStart; } else { isAmPmAtLeft = !isAmPmAtStart; } if (mIsAmPmAtLeft == isAmPmAtLeft) { // AM/PM is already at the correct location. No change needed. return; } if (isAmPmAtLeft) { params.removeRule(RelativeLayout.RIGHT_OF); params.addRule(RelativeLayout.LEFT_OF, mHourView.getId()); } else { params.removeRule(RelativeLayout.LEFT_OF); params.addRule(RelativeLayout.RIGHT_OF, mMinuteView.getId()); } mIsAmPmAtLeft = isAmPmAtLeft; } else if (params.getRule(RelativeLayout.BELOW) != 0 || params.getRule(RelativeLayout.ABOVE) != 0) { // Vertical mode, with AM/PM appearing to top/bottom of hours and minutes. if (mIsAmPmAtTop == isAmPmAtStart) { // AM/PM is already at the correct location. No change needed. return; } final int otherViewId; if (isAmPmAtStart) { otherViewId = params.getRule(RelativeLayout.BELOW); params.removeRule(RelativeLayout.BELOW); params.addRule(RelativeLayout.ABOVE, otherViewId); } else { otherViewId = params.getRule(RelativeLayout.ABOVE); params.removeRule(RelativeLayout.ABOVE); params.addRule(RelativeLayout.BELOW, otherViewId); } // Switch the top and bottom paddings on the other view. final View otherView = mRadialTimePickerHeader.findViewById(otherViewId); final int top = otherView.getPaddingTop(); final int bottom = otherView.getPaddingBottom(); final int left = otherView.getPaddingLeft(); final int right = otherView.getPaddingRight(); otherView.setPadding(left, bottom, right, top); mIsAmPmAtTop = isAmPmAtStart; } mAmPmLayout.setLayoutParams(params); }
Example 20
Source File: WallpaperCropActivity.java From LB-Launcher with Apache License 2.0 | 4 votes |
protected void cropImageAndSetWallpaper(Uri uri, OnBitmapCroppedHandler onBitmapCroppedHandler, final boolean finishActivityWhenDone) { boolean centerCrop = getResources().getBoolean(R.bool.center_crop); // Get the crop boolean ltr = mCropView.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR; Display d = getWindowManager().getDefaultDisplay(); Point displaySize = new Point(); d.getSize(displaySize); boolean isPortrait = displaySize.x < displaySize.y; Point defaultWallpaperSize = getDefaultWallpaperSize(getResources(), getWindowManager()); // Get the crop RectF cropRect = mCropView.getCrop(); Point inSize = mCropView.getSourceDimensions(); int cropRotation = mCropView.getImageRotation(); float cropScale = mCropView.getWidth() / (float) cropRect.width(); Matrix rotateMatrix = new Matrix(); rotateMatrix.setRotate(cropRotation); float[] rotatedInSize = new float[] { inSize.x, inSize.y }; rotateMatrix.mapPoints(rotatedInSize); rotatedInSize[0] = Math.abs(rotatedInSize[0]); rotatedInSize[1] = Math.abs(rotatedInSize[1]); // due to rounding errors in the cropview renderer the edges can be slightly offset // therefore we ensure that the boundaries are sanely defined cropRect.left = Math.max(0, cropRect.left); cropRect.right = Math.min(rotatedInSize[0], cropRect.right); cropRect.top = Math.max(0, cropRect.top); cropRect.bottom = Math.min(rotatedInSize[1], cropRect.bottom); // ADJUST CROP WIDTH // Extend the crop all the way to the right, for parallax // (or all the way to the left, in RTL) float extraSpace; if (centerCrop) { extraSpace = 2f * Math.min(rotatedInSize[0] - cropRect.right, cropRect.left); } else { extraSpace = ltr ? rotatedInSize[0] - cropRect.right : cropRect.left; } // Cap the amount of extra width float maxExtraSpace = defaultWallpaperSize.x / cropScale - cropRect.width(); extraSpace = Math.min(extraSpace, maxExtraSpace); if (centerCrop) { cropRect.left -= extraSpace / 2f; cropRect.right += extraSpace / 2f; } else { if (ltr) { cropRect.right += extraSpace; } else { cropRect.left -= extraSpace; } } // ADJUST CROP HEIGHT if (isPortrait) { cropRect.bottom = cropRect.top + defaultWallpaperSize.y / cropScale; } else { // LANDSCAPE float extraPortraitHeight = defaultWallpaperSize.y / cropScale - cropRect.height(); float expandHeight = Math.min(Math.min(rotatedInSize[1] - cropRect.bottom, cropRect.top), extraPortraitHeight / 2); cropRect.top -= expandHeight; cropRect.bottom += expandHeight; } final int outWidth = (int) Math.round(cropRect.width() * cropScale); final int outHeight = (int) Math.round(cropRect.height() * cropScale); Runnable onEndCrop = new Runnable() { public void run() { updateWallpaperDimensions(outWidth, outHeight); if (finishActivityWhenDone) { setResult(Activity.RESULT_OK); finish(); } } }; BitmapCropTask cropTask = new BitmapCropTask(this, uri, cropRect, cropRotation, outWidth, outHeight, true, false, onEndCrop); if (onBitmapCroppedHandler != null) { cropTask.setOnBitmapCropped(onBitmapCroppedHandler); } cropTask.execute(); }