本文整理匯總了Java中android.text.Layout.DIR_LEFT_TO_RIGHT屬性的典型用法代碼示例。如果您正苦於以下問題:Java Layout.DIR_LEFT_TO_RIGHT屬性的具體用法?Java Layout.DIR_LEFT_TO_RIGHT怎麽用?Java Layout.DIR_LEFT_TO_RIGHT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.text.Layout
的用法示例。
在下文中一共展示了Layout.DIR_LEFT_TO_RIGHT屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateUrlDirection
/**
* If the direction of the URL has changed, update mUrlDirection and notify the
* UrlDirectionListeners.
*/
private void updateUrlDirection() {
Layout layout = getLayout();
if (layout == null) return;
int urlDirection;
if (length() == 0) {
urlDirection = LAYOUT_DIRECTION_LOCALE;
} else if (layout.getParagraphDirection(0) == Layout.DIR_LEFT_TO_RIGHT) {
urlDirection = LAYOUT_DIRECTION_LTR;
} else {
urlDirection = LAYOUT_DIRECTION_RTL;
}
if (urlDirection != mUrlDirection) {
mUrlDirection = urlDirection;
if (mUrlDirectionListener != null) {
mUrlDirectionListener.onUrlDirectionChanged(urlDirection);
}
}
}
示例2: getTextDirection
private static String getTextDirection(Spanned text, int start, int end) {
// FIXME not supported
int paraDir = Layout.DIR_LEFT_TO_RIGHT;
// final int len = end - start;
// final byte[] levels = ArrayUtils.newUnpaddedByteArray(len);
// final char[] buffer = TextUtils.obtain(len);
// TextUtils.getChars(text, start, end, buffer, 0);
// int paraDir = AndroidBidi.bidi(Layout.DIR_REQUEST_DEFAULT_LTR, buffer, levels, len,
// false /* no info */);
switch (paraDir) {
case Layout.DIR_RIGHT_TO_LEFT:
return " dir=\"rtl\"";
case Layout.DIR_LEFT_TO_RIGHT:
default:
return " dir=\"ltr\"";
}
}