本文整理汇总了Java中android.support.v4.text.TextUtilsCompat.getLayoutDirectionFromLocale方法的典型用法代码示例。如果您正苦于以下问题:Java TextUtilsCompat.getLayoutDirectionFromLocale方法的具体用法?Java TextUtilsCompat.getLayoutDirectionFromLocale怎么用?Java TextUtilsCompat.getLayoutDirectionFromLocale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.text.TextUtilsCompat
的用法示例。
在下文中一共展示了TextUtilsCompat.getLayoutDirectionFromLocale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ListPopupWindow
import android.support.v4.text.TextUtilsCompat; //导入方法依赖的package包/类
/**
* Create a new, empty popup window capable of displaying items from a ListAdapter.
* Backgrounds should be set using {@link #setBackgroundDrawable(Drawable)}.
*
* @param context Context used for contained views.
* @param attrs Attributes from inflating parent views used to style the popup.
* @param defStyleAttr Default style attribute to use for popup content.
* @param defStyleRes Default style to use for popup content.
*/
public ListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
mContext = context;
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ListPopupWindow,
defStyleAttr, defStyleRes);
mDropDownHorizontalOffset = a.getDimensionPixelOffset(
R.styleable.ListPopupWindow_android_dropDownHorizontalOffset, 0);
mDropDownVerticalOffset = a.getDimensionPixelOffset(
R.styleable.ListPopupWindow_android_dropDownVerticalOffset, 0);
if (mDropDownVerticalOffset != 0) {
mDropDownVerticalOffsetSet = true;
}
a.recycle();
mPopup = new PopupWindow(context, attrs, defStyleAttr);
mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
// Set the default layout direction to match the default locale one
final Locale locale = mContext.getResources().getConfiguration().locale;
mLayoutDirection = TextUtilsCompat.getLayoutDirectionFromLocale(locale);
}
示例2: ListPopupWindow
import android.support.v4.text.TextUtilsCompat; //导入方法依赖的package包/类
/**
* Create a new, empty popup window capable of displaying items from a ListAdapter.
* Backgrounds should be set using {@link #setBackgroundDrawable(android.graphics.drawable.Drawable)}.
*
* @param context Context used for contained views.
* @param attrs Attributes from inflating parent views used to style the popup.
* @param defStyleAttr Default style attribute to use for popup content.
* @param defStyleRes Default style to use for popup content.
*/
public ListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
mContext = context;
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ListPopupWindow,
defStyleAttr, defStyleRes);
mDropDownHorizontalOffset = a.getDimensionPixelOffset(
R.styleable.ListPopupWindow_android_dropDownHorizontalOffset, 0);
mDropDownVerticalOffset = a.getDimensionPixelOffset(
R.styleable.ListPopupWindow_android_dropDownVerticalOffset, 0);
if (mDropDownVerticalOffset != 0) {
mDropDownVerticalOffsetSet = true;
}
a.recycle();
mPopup = new PopupWindow(context, attrs, defStyleAttr);
mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
// Set the default layout direction to match the default locale one
final Locale locale = mContext.getResources().getConfiguration().locale;
mLayoutDirection = TextUtilsCompat.getLayoutDirectionFromLocale(locale);
}
示例3: animateTransition
import android.support.v4.text.TextUtilsCompat; //导入方法依赖的package包/类
@SuppressLint("InlinedApi")
protected void animateTransition(FragmentTransaction transaction, int direction) {
boolean rtl = false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
rtl = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL;
}
if (direction == TRANSITION_HORIZONTAL) {
if (rtl) {
transaction.setCustomAnimations(R.animator.slide_left, R.animator.slide_right,
R.animator.slide_back_right, R.animator.slide_back_left);
} else {
transaction.setCustomAnimations(R.animator.slide_back_right, R.animator.slide_back_left,
R.animator.slide_left, R.animator.slide_right);
}
}
if (direction == TRANSITION_VERTICAL && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
transaction.setCustomAnimations(
R.animator.anim_in, R.animator.anim_out, R.animator.anim_in_pop, R.animator.anim_out_pop);
}
}
示例4: snap
import android.support.v4.text.TextUtilsCompat; //导入方法依赖的package包/类
protected void snap(@NonNull View subject, @Nullable String... dataPoints) {
int rtl = layoutDirection == LayoutDirection.RTL
? View.LAYOUT_DIRECTION_RTL
: TextUtilsCompat.getLayoutDirectionFromLocale(locale);
//noinspection WrongConstant
subject.setLayoutDirection(rtl);
ViewHelpers viewHelpers = ViewHelpers.setupView(subject).setExactWidthDp(widthDp);
if (heightDp != null) {
viewHelpers.setExactHeightDp(heightDp);
}
viewHelpers.layout();
List<String> list = new ArrayList<>();
String byHeight = heightDp == null ? "" : ("x" + heightDp);
list.add(widthDp + byHeight + "dp");
list.add(locale.toString());
list.add(layoutDirection == LayoutDirection.RTL ? "rtl" : "ltr");
list.add("font" + fontScale.multiplier() + "x");
list.add(theme.toString().toLowerCase(Locale.ENGLISH));
list.addAll(Arrays.asList(ArrayUtils.nullToEmpty(dataPoints)));
Screenshot.snap(subject).setName(testName(list)).record();
}
示例5: LabelSpan
import android.support.v4.text.TextUtilsCompat; //导入方法依赖的package包/类
public LabelSpan(int color) {
this(color, new SpanDimensions() {
@Override public int getPadding() {
return 6;
}
@Override public int getPaddingExtraWidth() {
return 0;
}
@Override public int getPaddingAfter() {
return 0;
}
@Override public int getMaxWidth() {
return 1000;//random number
}
@Override public float getRoundedCornerRadius() {
return 5;
}
@Override public int getMarginTop() {
return 8;
}
@Override public boolean isRtl() {
return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL;
}
});
}
示例6: getInstance
import android.support.v4.text.TextUtilsCompat; //导入方法依赖的package包/类
public static GravityCompatHelper getInstance() {
if (mHelper == null) {
mHelper = new GravityCompatHelper();
}
layoutDirection = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault());
return mHelper;
}
示例7: ListPopupWindow
import android.support.v4.text.TextUtilsCompat; //导入方法依赖的package包/类
public ListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
this.mDropDownHeight = -2;
this.mDropDownWidth = -2;
this.mDropDownWindowLayoutType = 1002;
this.mDropDownGravity = 0;
this.mDropDownAlwaysVisible = false;
this.mForceIgnoreOutsideTouch = false;
this.mListItemExpandMaximum = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED;
this.mPromptPosition = 0;
this.mResizePopupRunnable = new ResizePopupRunnable();
this.mTouchInterceptor = new PopupTouchInterceptor();
this.mScrollListener = new PopupScrollListener();
this.mHideSelector = new ListSelectorHider();
this.mTempRect = new Rect();
this.mContext = context;
this.mHandler = new Handler(context.getMainLooper());
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ListPopupWindow, defStyleAttr, defStyleRes);
this.mDropDownHorizontalOffset = a.getDimensionPixelOffset(R.styleable.ListPopupWindow_android_dropDownHorizontalOffset, 0);
this.mDropDownVerticalOffset = a.getDimensionPixelOffset(R.styleable.ListPopupWindow_android_dropDownVerticalOffset, 0);
if (this.mDropDownVerticalOffset != 0) {
this.mDropDownVerticalOffsetSet = true;
}
a.recycle();
this.mPopup = new AppCompatPopupWindow(context, attrs, defStyleAttr);
this.mPopup.setInputMethodMode(1);
this.mLayoutDirection = TextUtilsCompat.getLayoutDirectionFromLocale(this.mContext.getResources().getConfiguration().locale);
}
示例8: setLayoutDirection
import android.support.v4.text.TextUtilsCompat; //导入方法依赖的package包/类
/**
* Force set layout direction to RTL or LTR by Locale.
*
* @param view
* @param locale
*/
public static void setLayoutDirection(View view, Locale locale) {
switch (TextUtilsCompat.getLayoutDirectionFromLocale(locale)) {
case ViewCompat.LAYOUT_DIRECTION_RTL:
ViewCompat.setLayoutDirection(view, ViewCompat.LAYOUT_DIRECTION_RTL);
break;
case ViewCompat.LAYOUT_DIRECTION_LTR:
default:
ViewCompat.setLayoutDirection(view, ViewCompat.LAYOUT_DIRECTION_LTR);
break;
}
}
示例9: ListPopupWindow
import android.support.v4.text.TextUtilsCompat; //导入方法依赖的package包/类
public ListPopupWindow(Context paramContext, AttributeSet paramAttributeSet, int paramInt1, int paramInt2)
{
this.mContext = paramContext;
this.mHandler = new Handler(paramContext.getMainLooper());
TypedArray localTypedArray = paramContext.obtainStyledAttributes(paramAttributeSet, R.styleable.ListPopupWindow, paramInt1, paramInt2);
this.mDropDownHorizontalOffset = localTypedArray.getDimensionPixelOffset(R.styleable.ListPopupWindow_android_dropDownHorizontalOffset, 0);
this.mDropDownVerticalOffset = localTypedArray.getDimensionPixelOffset(R.styleable.ListPopupWindow_android_dropDownVerticalOffset, 0);
if (this.mDropDownVerticalOffset != 0) {
this.mDropDownVerticalOffsetSet = true;
}
localTypedArray.recycle();
this.mPopup = new AppCompatPopupWindow(paramContext, paramAttributeSet, paramInt1);
this.mPopup.setInputMethodMode(1);
this.mLayoutDirection = TextUtilsCompat.getLayoutDirectionFromLocale(this.mContext.getResources().getConfiguration().locale);
}
示例10: adjustIndexForDirectionality
import android.support.v4.text.TextUtilsCompat; //导入方法依赖的package包/类
private static int adjustIndexForDirectionality(int index) {
if (TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault())
== ViewCompat.LAYOUT_DIRECTION_RTL) {
return CBD_TAB_COUNT - 1 - index;
}
return index;
}
示例11: ListPopupWindow
import android.support.v4.text.TextUtilsCompat; //导入方法依赖的package包/类
public ListPopupWindow(Context context, AttributeSet attributeset, int i, int j)
{
mDropDownHeight = -2;
mDropDownWidth = -2;
mDropDownGravity = 0;
mDropDownAlwaysVisible = false;
mForceIgnoreOutsideTouch = false;
mListItemExpandMaximum = 0x7fffffff;
mPromptPosition = 0;
mResizePopupRunnable = new ResizePopupRunnable();
mTouchInterceptor = new PopupTouchInterceptor();
mScrollListener = new PopupScrollListener();
mHideSelector = new ListSelectorHider();
mHandler = new Handler();
mTempRect = new Rect();
mContext = context;
TypedArray typedarray = context.obtainStyledAttributes(attributeset, android.support.v7.appcompat.R.styleable.ListPopupWindow, i, j);
mDropDownHorizontalOffset = typedarray.getDimensionPixelOffset(android.support.v7.appcompat.R.styleable.ListPopupWindow_android_dropDownHorizontalOffset, 0);
mDropDownVerticalOffset = typedarray.getDimensionPixelOffset(android.support.v7.appcompat.R.styleable.ListPopupWindow_android_dropDownVerticalOffset, 0);
if (mDropDownVerticalOffset != 0)
{
mDropDownVerticalOffsetSet = true;
}
typedarray.recycle();
mPopup = new AppCompatPopupWindow(context, attributeset, i);
mPopup.setInputMethodMode(1);
mLayoutDirection = TextUtilsCompat.getLayoutDirectionFromLocale(mContext.getResources().getConfiguration().locale);
}
示例12: isRtl
import android.support.v4.text.TextUtilsCompat; //导入方法依赖的package包/类
public static boolean isRtl() {
return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault())
== ViewCompat.LAYOUT_DIRECTION_RTL;
}
示例13: isRTL
import android.support.v4.text.TextUtilsCompat; //导入方法依赖的package包/类
public static boolean isRTL() {
return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault())
== android.support.v4.view.ViewCompat.LAYOUT_DIRECTION_RTL;
}
示例14: isDevicePreferredLanguageRTL
import android.support.v4.text.TextUtilsCompat; //导入方法依赖的package包/类
private boolean isDevicePreferredLanguageRTL() {
final int directionality =
TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault());
return directionality == ViewCompat.LAYOUT_DIRECTION_RTL;
}
示例15: onSizeChanged
import android.support.v4.text.TextUtilsCompat; //导入方法依赖的package包/类
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mOriginalTextColors = getTextColors();
if (mOriginalTextColors != null) {
mLastCharPaint.setColor(mOriginalTextColors.getDefaultColor());
mCharPaint.setColor(mOriginalTextColors.getDefaultColor());
mSingleCharPaint.setColor(getCurrentHintTextColor());
}
int availableWidth = getWidth() - ViewCompat.getPaddingEnd(this) - ViewCompat.getPaddingStart(this);
if (mSpace < 0) {
mCharSize = (availableWidth / (mNumChars * 2 - 1));
} else {
mCharSize = (availableWidth - (mSpace * (mNumChars - 1))) / mNumChars;
}
mLineCoords = new RectF[(int) mNumChars];
mCharBottom = new float[(int) mNumChars];
int startX;
int bottom = getHeight() - getPaddingBottom();
int rtlFlag;
final boolean isLayoutRtl = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL;
if (isLayoutRtl) {
rtlFlag = -1;
startX = (int) (getWidth() - ViewCompat.getPaddingStart(this) - mCharSize);
} else {
rtlFlag = 1;
startX = ViewCompat.getPaddingStart(this);
}
for (int i = 0; i < mNumChars; i++) {
mLineCoords[i] = new RectF(startX, bottom, startX + mCharSize, bottom);
if (mPinBackground != null) {
if (mIsDigitSquare) {
mLineCoords[i].top = getPaddingTop();
mLineCoords[i].right = startX + mLineCoords[i].height();
} else {
mLineCoords[i].top -= mTextHeight.height() + mTextBottomPadding * 2;
}
}
if (mSpace < 0) {
startX += rtlFlag * mCharSize * 2;
} else {
startX += rtlFlag * (mCharSize + mSpace);
}
mCharBottom[i] = mLineCoords[i].bottom - mTextBottomPadding;
}
}