Java Code Examples for android.support.v4.view.ViewCompat#setLayoutDirection()
The following examples show how to use
android.support.v4.view.ViewCompat#setLayoutDirection() .
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: IndicatorDots.java From PinLockView with Apache License 2.0 | 6 votes |
private void initView(Context context) { ViewCompat.setLayoutDirection(this, ViewCompat.LAYOUT_DIRECTION_LTR); if (mIndicatorType == 0) { for (int i = 0; i < mPinLength; i++) { View dot = new View(context); emptyDot(dot); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(mDotDiameter, mDotDiameter); params.setMargins(mDotSpacing, 0, mDotSpacing, 0); dot.setLayoutParams(params); addView(dot); } } else if (mIndicatorType == 2) { setLayoutTransition(new LayoutTransition()); } }
Example 2
Source File: SimpleDialog.java From timecat with Apache License 2.0 | 5 votes |
private void initScrollView() { mScrollView = new InternalScrollView(getContext()); mScrollView.setPadding(0, 0, 0, mContentPadding - mActionPadding_h); mScrollView.setClipToPadding(false); mScrollView.setFillViewport(true); mScrollView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); ViewCompat.setLayoutDirection(mScrollView, View.LAYOUT_DIRECTION_INHERIT); }
Example 3
Source File: SimpleDialog.java From timecat with Apache License 2.0 | 5 votes |
private void initListView() { mListView = new InternalListView(getContext()); mListView.setDividerHeight(0); mListView.setCacheColorHint(0x00000000); mListView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); mListView.setClipToPadding(false); mListView.setSelector(BlankDrawable.getInstance()); mListView.setPadding(0, 0, 0, mContentPadding - mActionPadding_h); mListView.setVerticalFadingEdgeEnabled(false); mListView.setOverScrollMode(ListView.OVER_SCROLL_NEVER); ViewCompat.setLayoutDirection(mListView, ViewCompat.LAYOUT_DIRECTION_INHERIT); mAdapter = new InternalAdapter(); mListView.setAdapter(mAdapter); }
Example 4
Source File: KeyboardAwareEditText.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 5 votes |
public void correctDiretion() { boolean numIsRtl=true; if (ViewCompat.getLayoutDirection(this) != View.LAYOUT_DIRECTION_RTL) { numIsRtl = false; } ViewCompat.setLayoutDirection(this, View.LAYOUT_DIRECTION_LTR); this.setGravity(numIsRtl ? Gravity.LEFT : Gravity.RIGHT); }
Example 5
Source File: SimpleDialog.java From MDPreference with Apache License 2.0 | 5 votes |
private void initScrollView() { mScrollView = new InternalScrollView(getContext()); mScrollView.setPadding(0, 0, 0, mContentPadding - mActionPadding); mScrollView.setClipToPadding(false); mScrollView.setFillViewport(true); mScrollView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); ViewCompat.setLayoutDirection(mScrollView, ViewCompat.LAYOUT_DIRECTION_INHERIT); }
Example 6
Source File: SimpleDialog.java From MDPreference with Apache License 2.0 | 5 votes |
private void initListView() { mListView = new InternalListView(getContext()); mListView.setDividerHeight(0); mListView.setCacheColorHint(0x00000000); mListView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); mListView.setClipToPadding(false); mListView.setSelector(BlankDrawable.getInstance()); mListView.setPadding(0, 0, 0, mContentPadding - mActionPadding); mListView.setVerticalFadingEdgeEnabled(false); mListView.setOverScrollMode(ListView.OVER_SCROLL_NEVER); ViewCompat.setLayoutDirection(mListView, ViewCompat.LAYOUT_DIRECTION_INHERIT); mAdapter = new InternalAdapter(); mListView.setAdapter(mAdapter); }
Example 7
Source File: RTLRowTest.java From ChipsLayoutManager with Apache License 2.0 | 5 votes |
@UiThread @Override protected ChipsLayoutManager getLayoutManager() { ChipsLayoutManager layoutManager = super.getLayoutManager(); if (activityTestRule.getActivity() != null) { View recyclerView = activityTestRule.getActivity().findViewById(R.id.rvTest); ViewCompat.setLayoutDirection(recyclerView, ViewCompat.LAYOUT_DIRECTION_RTL); } return layoutManager; }
Example 8
Source File: PasswordEditTextTest.java From materialandroid with Apache License 2.0 | 5 votes |
@Test @Config(sdk = 16) public void givenLessThanSdk17TouchWithinToggle_whenOnTouchEvent_thenPasswordVisibilityToggled() { ViewCompat.setLayoutDirection(passwordView, ViewCompat.LAYOUT_DIRECTION_RTL); passwordView.setPasswordVisible(false); float xPosition = passwordView.getRight() - 10; float yPosition = passwordView.getTop() + 10; fireActionUpTouchEvent(passwordView, xPosition, yPosition); assertThat(passwordView) .hasVisiblePassword(); }
Example 9
Source File: CustomInputStyleSettingsFragment.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = super.onCreateView(inflater, container, savedInstanceState); // For correct display in RTL locales, we need to set the layout direction of the // fragment's top view. ViewCompat.setLayoutDirection(view, ViewCompat.LAYOUT_DIRECTION_LOCALE); return view; }
Example 10
Source File: SuggestionStripView.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
public void setLayoutDirection(final boolean isRtlLanguage) { final int layoutDirection = isRtlLanguage ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR; ViewCompat.setLayoutDirection(mSuggestionStripView, layoutDirection); ViewCompat.setLayoutDirection(mSuggestionsStrip, layoutDirection); ViewCompat.setLayoutDirection(mImportantNoticeStrip, layoutDirection); }
Example 11
Source File: SuggestionView.java From delion with Apache License 2.0 | 4 votes |
/** * Sets the contents and state of the view for the given suggestion. * * @param suggestionItem The omnibox suggestion item this view represents. * @param suggestionDelegate The suggestion delegate. * @param position Position of the suggestion in the dropdown list. * @param useDarkColors Whether dark colors should be used for fonts and icons. */ public void init(OmniboxResultItem suggestionItem, OmniboxSuggestionDelegate suggestionDelegate, int position, boolean useDarkColors) { ViewCompat.setLayoutDirection(this, ViewCompat.getLayoutDirection(mUrlBar)); // Update the position unconditionally. mPosition = position; jumpDrawablesToCurrentState(); boolean colorsChanged = mUseDarkColors == null || mUseDarkColors != useDarkColors; if (suggestionItem.equals(mSuggestionItem) && !colorsChanged) return; mUseDarkColors = useDarkColors; if (colorsChanged) { mContentsView.mTextLine1.setTextColor(getStandardFontColor()); setRefineIcon(true); } mSuggestionItem = suggestionItem; mSuggestion = suggestionItem.getSuggestion(); mSuggestionDelegate = suggestionDelegate; // Reset old computations. mContentsView.resetTextWidths(); mContentsView.mAnswerImage.setVisibility(GONE); mContentsView.mAnswerImage.getLayoutParams().height = 0; mContentsView.mAnswerImage.getLayoutParams().width = 0; mContentsView.mAnswerImage.setImageDrawable(null); mContentsView.mAnswerImageMaxSize = 0; mContentsView.mTextLine1.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources() .getDimension(R.dimen.omnibox_suggestion_first_line_text_size)); mContentsView.mTextLine2.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources() .getDimension(R.dimen.omnibox_suggestion_second_line_text_size)); // Suggestions with attached answers are rendered with rich results regardless of which // suggestion type they are. if (mSuggestion.hasAnswer()) { setAnswer(mSuggestion.getAnswer()); mContentsView.setSuggestionIcon(SUGGESTION_ICON_MAGNIFIER, colorsChanged); mContentsView.mTextLine2.setVisibility(VISIBLE); setRefinable(true); return; } else { mNumAnswerLines = 1; mContentsView.mTextLine2.setEllipsize(null); mContentsView.mTextLine2.setSingleLine(); } boolean sameAsTyped = suggestionItem.getMatchedQuery().equalsIgnoreCase(mSuggestion.getDisplayText()); int suggestionType = mSuggestion.getType(); if (mSuggestion.isUrlSuggestion()) { if (mSuggestion.isStarred()) { mContentsView.setSuggestionIcon(SUGGESTION_ICON_BOOKMARK, colorsChanged); } else if (suggestionType == OmniboxSuggestionType.HISTORY_URL) { mContentsView.setSuggestionIcon(SUGGESTION_ICON_HISTORY, colorsChanged); } else { mContentsView.setSuggestionIcon(SUGGESTION_ICON_GLOBE, colorsChanged); } boolean urlShown = !TextUtils.isEmpty(mSuggestion.getUrl()); boolean urlHighlighted = false; if (urlShown) { urlHighlighted = setUrlText(suggestionItem); } else { mContentsView.mTextLine2.setVisibility(INVISIBLE); } setSuggestedQuery(suggestionItem, true, urlShown, urlHighlighted); setRefinable(!sameAsTyped); } else { @SuggestionIcon int suggestionIcon = SUGGESTION_ICON_MAGNIFIER; if (suggestionType == OmniboxSuggestionType.VOICE_SUGGEST) { suggestionIcon = SUGGESTION_ICON_VOICE; } else if ((suggestionType == OmniboxSuggestionType.SEARCH_SUGGEST_PERSONALIZED) || (suggestionType == OmniboxSuggestionType.SEARCH_HISTORY)) { // Show history icon for suggestions based on user queries. suggestionIcon = SUGGESTION_ICON_HISTORY; } mContentsView.setSuggestionIcon(suggestionIcon, colorsChanged); setRefinable(!sameAsTyped); setSuggestedQuery(suggestionItem, false, false, false); if ((suggestionType == OmniboxSuggestionType.SEARCH_SUGGEST_ENTITY) || (suggestionType == OmniboxSuggestionType.SEARCH_SUGGEST_PROFILE)) { showDescriptionLine(SpannableString.valueOf(mSuggestion.getDescription()), false); } else { mContentsView.mTextLine2.setVisibility(INVISIBLE); } } }
Example 12
Source File: SuggestionView.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** * Sets the contents and state of the view for the given suggestion. * * @param suggestionItem The omnibox suggestion item this view represents. * @param suggestionDelegate The suggestion delegate. * @param position Position of the suggestion in the dropdown list. * @param useDarkColors Whether dark colors should be used for fonts and icons. */ public void init(OmniboxResultItem suggestionItem, OmniboxSuggestionDelegate suggestionDelegate, int position, boolean useDarkColors) { ViewCompat.setLayoutDirection(this, ViewCompat.getLayoutDirection(mUrlBar)); // Update the position unconditionally. mPosition = position; jumpDrawablesToCurrentState(); boolean colorsChanged = mUseDarkColors == null || mUseDarkColors != useDarkColors; if (suggestionItem.equals(mSuggestionItem) && !colorsChanged) return; mUseDarkColors = useDarkColors; if (colorsChanged) { mContentsView.mTextLine1.setTextColor(getStandardFontColor()); setRefineIcon(true); } mSuggestionItem = suggestionItem; mSuggestion = suggestionItem.getSuggestion(); mSuggestionDelegate = suggestionDelegate; // Reset old computations. mContentsView.resetTextWidths(); mContentsView.mAnswerImage.setVisibility(GONE); mContentsView.mAnswerImage.getLayoutParams().height = 0; mContentsView.mAnswerImage.getLayoutParams().width = 0; mContentsView.mAnswerImage.setImageDrawable(null); mContentsView.mAnswerImageMaxSize = 0; mContentsView.mTextLine1.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources() .getDimension(R.dimen.omnibox_suggestion_first_line_text_size)); mContentsView.mTextLine2.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources() .getDimension(R.dimen.omnibox_suggestion_second_line_text_size)); // Suggestions with attached answers are rendered with rich results regardless of which // suggestion type they are. if (mSuggestion.hasAnswer()) { setAnswer(mSuggestion.getAnswer()); mContentsView.setSuggestionIcon(SUGGESTION_ICON_MAGNIFIER, colorsChanged); mContentsView.mTextLine2.setVisibility(VISIBLE); setRefinable(true); return; } else { mNumAnswerLines = 1; mContentsView.mTextLine2.setEllipsize(null); mContentsView.mTextLine2.setSingleLine(); } boolean sameAsTyped = suggestionItem.getMatchedQuery().equalsIgnoreCase(mSuggestion.getDisplayText()); int suggestionType = mSuggestion.getType(); if (mSuggestion.isUrlSuggestion()) { if (mSuggestion.isStarred()) { mContentsView.setSuggestionIcon(SUGGESTION_ICON_BOOKMARK, colorsChanged); } else if (suggestionType == OmniboxSuggestionType.HISTORY_URL) { mContentsView.setSuggestionIcon(SUGGESTION_ICON_HISTORY, colorsChanged); } else { mContentsView.setSuggestionIcon(SUGGESTION_ICON_GLOBE, colorsChanged); } boolean urlShown = !TextUtils.isEmpty(mSuggestion.getUrl()); boolean urlHighlighted = false; if (urlShown) { urlHighlighted = setUrlText(suggestionItem); } else { mContentsView.mTextLine2.setVisibility(INVISIBLE); } setSuggestedQuery(suggestionItem, true, urlShown, urlHighlighted); setRefinable(!sameAsTyped); } else { @SuggestionIcon int suggestionIcon = SUGGESTION_ICON_MAGNIFIER; if (suggestionType == OmniboxSuggestionType.VOICE_SUGGEST) { suggestionIcon = SUGGESTION_ICON_VOICE; } else if ((suggestionType == OmniboxSuggestionType.SEARCH_SUGGEST_PERSONALIZED) || (suggestionType == OmniboxSuggestionType.SEARCH_HISTORY)) { // Show history icon for suggestions based on user queries. suggestionIcon = SUGGESTION_ICON_HISTORY; } mContentsView.setSuggestionIcon(suggestionIcon, colorsChanged); setRefinable(!sameAsTyped); setSuggestedQuery(suggestionItem, false, false, false); if ((suggestionType == OmniboxSuggestionType.SEARCH_SUGGEST_ENTITY) || (suggestionType == OmniboxSuggestionType.SEARCH_SUGGEST_PROFILE)) { showDescriptionLine(SpannableString.valueOf(mSuggestion.getDescription()), false); } else { mContentsView.mTextLine2.setVisibility(INVISIBLE); } } }
Example 13
Source File: SuggestionView.java From 365browser with Apache License 2.0 | 4 votes |
/** * Sets the contents and state of the view for the given suggestion. * * @param suggestionItem The omnibox suggestion item this view represents. * @param suggestionDelegate The suggestion delegate. * @param position Position of the suggestion in the dropdown list. * @param useDarkColors Whether dark colors should be used for fonts and icons. */ public void init(OmniboxResultItem suggestionItem, OmniboxSuggestionDelegate suggestionDelegate, int position, boolean useDarkColors) { ViewCompat.setLayoutDirection(this, ViewCompat.getLayoutDirection(mUrlBar)); // Update the position unconditionally. mPosition = position; jumpDrawablesToCurrentState(); boolean colorsChanged = mUseDarkColors == null || mUseDarkColors != useDarkColors; if (suggestionItem.equals(mSuggestionItem) && !colorsChanged) return; mUseDarkColors = useDarkColors; if (colorsChanged) { mContentsView.mTextLine1.setTextColor(getStandardFontColor()); setRefineIcon(true); } mSuggestionItem = suggestionItem; mSuggestion = suggestionItem.getSuggestion(); mSuggestionDelegate = suggestionDelegate; // Reset old computations. mContentsView.resetTextWidths(); mContentsView.mAnswerImage.setVisibility(GONE); mContentsView.mAnswerImage.getLayoutParams().height = 0; mContentsView.mAnswerImage.getLayoutParams().width = 0; mContentsView.mAnswerImage.setImageDrawable(null); mContentsView.mAnswerImageMaxSize = 0; mContentsView.mTextLine1.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources() .getDimension(R.dimen.omnibox_suggestion_first_line_text_size)); mContentsView.mTextLine2.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources() .getDimension(R.dimen.omnibox_suggestion_second_line_text_size)); // Suggestions with attached answers are rendered with rich results regardless of which // suggestion type they are. if (mSuggestion.hasAnswer()) { setAnswer(mSuggestion.getAnswer()); mContentsView.setSuggestionIcon(SUGGESTION_ICON_MAGNIFIER, colorsChanged); mContentsView.mTextLine2.setVisibility(VISIBLE); setRefinable(true); return; } else { mNumAnswerLines = 1; mContentsView.mTextLine2.setEllipsize(null); mContentsView.mTextLine2.setSingleLine(); } boolean sameAsTyped = suggestionItem.getMatchedQuery().equalsIgnoreCase(mSuggestion.getDisplayText()); int suggestionType = mSuggestion.getType(); if (mSuggestion.isUrlSuggestion()) { if (mSuggestion.isStarred()) { mContentsView.setSuggestionIcon(SUGGESTION_ICON_BOOKMARK, colorsChanged); } else if (suggestionType == OmniboxSuggestionType.HISTORY_URL) { mContentsView.setSuggestionIcon(SUGGESTION_ICON_HISTORY, colorsChanged); } else { mContentsView.setSuggestionIcon(SUGGESTION_ICON_GLOBE, colorsChanged); } boolean urlShown = !TextUtils.isEmpty(mSuggestion.getUrl()); boolean urlHighlighted = false; if (urlShown) { urlHighlighted = setUrlText(suggestionItem); } else { mContentsView.mTextLine2.setVisibility(INVISIBLE); } setSuggestedQuery(suggestionItem, true, urlShown, urlHighlighted); setRefinable(!sameAsTyped && suggestionType != OmniboxSuggestionType.PHYSICAL_WEB_OVERFLOW); } else { @SuggestionIcon int suggestionIcon = SUGGESTION_ICON_MAGNIFIER; if (suggestionType == OmniboxSuggestionType.VOICE_SUGGEST) { suggestionIcon = SUGGESTION_ICON_VOICE; } else if ((suggestionType == OmniboxSuggestionType.SEARCH_SUGGEST_PERSONALIZED) || (suggestionType == OmniboxSuggestionType.SEARCH_HISTORY)) { // Show history icon for suggestions based on user queries. suggestionIcon = SUGGESTION_ICON_HISTORY; } mContentsView.setSuggestionIcon(suggestionIcon, colorsChanged); setRefinable(!sameAsTyped); setSuggestedQuery(suggestionItem, false, false, false); if ((suggestionType == OmniboxSuggestionType.SEARCH_SUGGEST_ENTITY) || (suggestionType == OmniboxSuggestionType.SEARCH_SUGGEST_PROFILE)) { showDescriptionLine(SpannableString.valueOf(mSuggestion.getDescription()), false); } else { mContentsView.mTextLine2.setVisibility(INVISIBLE); } } }
Example 14
Source File: Dialog.java From timecat with Apache License 2.0 | 2 votes |
/** * Set the layout direction of this Dialog * * @param direction The layout direction value. Can be {@link View#LAYOUT_DIRECTION_LTR}, {@link View#LAYOUT_DIRECTION_RTL} or {@link View#LAYOUT_DIRECTION_LOCALE} * * @return The Dialog for chaining methods. */ public Dialog layoutDirection(int direction) { ViewCompat.setLayoutDirection(mCardView, direction); return this; }
Example 15
Source File: ViewMaker.java From iGap-Android with GNU Affero General Public License v3.0 | 2 votes |
public static void setLayoutDirection(View view, int direction) { ViewCompat.setLayoutDirection(view, direction); }
Example 16
Source File: Dialog.java From MDPreference with Apache License 2.0 | 2 votes |
/** * Set the layout direction of this Dialog * * @param direction The layout direction value. Can be {@link View#LAYOUT_DIRECTION_LTR}, {@link View#LAYOUT_DIRECTION_RTL} or {@link View#LAYOUT_DIRECTION_LOCALE} * @return The Dialog for chaining methods. */ public Dialog layoutDirection(int direction) { ViewCompat.setLayoutDirection(mCardView, direction); return this; }