本文整理汇总了Java中org.chromium.base.ApiCompatibilityUtils.setTextDirection方法的典型用法代码示例。如果您正苦于以下问题:Java ApiCompatibilityUtils.setTextDirection方法的具体用法?Java ApiCompatibilityUtils.setTextDirection怎么用?Java ApiCompatibilityUtils.setTextDirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.chromium.base.ApiCompatibilityUtils
的用法示例。
在下文中一共展示了ApiCompatibilityUtils.setTextDirection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showDescriptionLine
import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
/**
* Sets a description line for the omnibox suggestion.
*
* @param str The description text.
* @param isUrl Whether this text is a URL (as opposed to a normal string).
*/
private void showDescriptionLine(Spannable str, boolean isUrl) {
TextView textLine = mContentsView.mTextLine2;
if (textLine.getVisibility() != VISIBLE) {
textLine.setVisibility(VISIBLE);
}
textLine.setText(str, BufferType.SPANNABLE);
// Force left-to-right rendering for URLs. See UrlBar constructor for details.
if (isUrl) {
textLine.setTextColor(URL_COLOR);
ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_LTR);
} else {
textLine.setTextColor(getStandardFontColor());
ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_INHERIT);
}
}
示例2: fixupTextDirection
import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
/**
* Sets the {@link UrlBar}'s text direction based on focus and contents.
*
* Should be called whenever focus or text contents change.
*/
private void fixupTextDirection() {
// When unfocused, force left-to-right rendering at the paragraph level (which is desired
// for URLs). Right-to-left runs are still rendered RTL, but will not flip the whole URL
// around. This is consistent with OmniboxViewViews on desktop. When focused, render text
// normally (to allow users to make non-URL searches and to avoid showing Android's split
// insertion point when an RTL user enters RTL text). Also render text normally when the
// text field is empty (because then it displays an instruction that is not a URL).
if (mFocused || length() == 0) {
ApiCompatibilityUtils.setTextDirection(this, TEXT_DIRECTION_INHERIT);
} else {
ApiCompatibilityUtils.setTextDirection(this, TEXT_DIRECTION_LTR);
}
}