本文整理汇总了Java中android.support.v4.text.TextUtilsCompat类的典型用法代码示例。如果您正苦于以下问题:Java TextUtilsCompat类的具体用法?Java TextUtilsCompat怎么用?Java TextUtilsCompat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextUtilsCompat类属于android.support.v4.text包,在下文中一共展示了TextUtilsCompat类的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: convertMarkup
import android.support.v4.text.TextUtilsCompat; //导入依赖的package包/类
@Override
public String convertMarkup(String markup, Context context) {
AppSettings as = new AppSettings(context);
String html = HTML100_BODY_PRE_BEGIN.replace("%FONT%", as.getFontFamily())
+ TextUtilsCompat.htmlEncode(markup)
+ HTML101_BODY_PRE_END;
return putContentIntoTemplate(context, html);
}
示例6: convertMarkup
import android.support.v4.text.TextUtilsCompat; //导入依赖的package包/类
@Override
public String convertMarkup(String markup, Context context) {
AppSettings as = new AppSettings(context);
String html = HTML100_BODY_PRE_BEGIN.replace("%FONT%", as.getFontFamily())
+ parse(TextUtilsCompat.htmlEncode(markup))
+ HTML101_BODY_PRE_END;
return putContentIntoTemplate(context, html);
}
示例7: 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;
}
});
}
示例8: 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;
}
示例9: 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);
}
示例10: 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;
}
}
示例11: 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);
}
示例12: 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;
}
示例13: 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);
}
示例14: isRtl
import android.support.v4.text.TextUtilsCompat; //导入依赖的package包/类
public static boolean isRtl() {
return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault())
== ViewCompat.LAYOUT_DIRECTION_RTL;
}
示例15: 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;
}