List of usage examples for android.support.v4.widget TextViewCompat setTextAppearance
public static void setTextAppearance(@NonNull TextView textView, @StyleRes int resId)
From source file:android.support.design.internal.NavigationMenuItemView.java
public void setTextAppearance(int textAppearance) { TextViewCompat.setTextAppearance(mTextView, textAppearance); }
From source file:com.ruesga.rview.drawer.DrawerNavigationMenuItemView.java
public void setTextAppearance(int textAppearance) { TextViewCompat.setTextAppearance(mTextView, textAppearance); TextViewCompat.setTextAppearance(mSubTextView, textAppearance); }
From source file:com.fastaccess.ui.modules.repos.RepoPagerView.java
@Override public void onInitRepo() { if (getPresenter().getRepo() == null) { return;/*from w ww . ja v a 2 s . c o m*/ } bottomNavigation.setOnMenuItemClickListener(getPresenter()); Repo repoModel = getPresenter().getRepo(); hideProgress(); detailsIcon.setVisibility(InputHelper.isEmpty(repoModel.getDescription()) ? View.GONE : View.VISIBLE); language.setVisibility(InputHelper.isEmpty(repoModel.getLanguage()) ? View.GONE : View.VISIBLE); if (!InputHelper.isEmpty(repoModel.getLanguage())) language.setText(repoModel.getLanguage()); language.setTextColor(ColorGenerator.MATERIAL.getColor(repoModel.getLanguage())); forkRepo.setText(numberFormat.format(repoModel.getForksCount())); starRepo.setText(numberFormat.format(repoModel.getStargazersCount())); watchRepo.setText(numberFormat.format(repoModel.getSubsCount())); if (repoModel.getOwner() != null) { avatarLayout.setUrl(repoModel.getOwner().getAvatarUrl(), repoModel.getOwner().getLogin()); } else if (repoModel.getOrganization() != null) { avatarLayout.setUrl(repoModel.getOrganization().getAvatarUrl(), repoModel.getOrganization().getLogin()); } date.setText(ParseDateFormat.getTimeAgo(repoModel.getUpdatedAt())); size.setVisibility(View.GONE); title.setText(repoModel.getFullName()); TextViewCompat.setTextAppearance(title, R.style.TextAppearance_AppCompat_Medium); title.setTextColor(ContextCompat.getColor(this, R.color.primary_text)); if (!InputHelper.isEmpty(repoModel.getLicense())) { licenseLayout.setVisibility(View.VISIBLE); license.setText(repoModel.getLicense().getSpdxId()); } supportInvalidateOptionsMenu(); if (!PrefGetter.isRepoGuideShowed()) {// the mother of nesting. #dontjudgeme. new MaterialTapTargetPrompt.Builder(this).setTarget(watchRepo).setPrimaryText(R.string.watch) .setSecondaryText(R.string.watch_hint).setCaptureTouchEventOutsidePrompt(true) .setOnHidePromptListener(new MaterialTapTargetPrompt.OnHidePromptListener() { @Override public void onHidePrompt(MotionEvent event, boolean tappedTarget) { } @Override public void onHidePromptComplete() { new MaterialTapTargetPrompt.Builder(RepoPagerView.this).setTarget(starRepo) .setPrimaryText(R.string.star).setSecondaryText(R.string.star_hint) .setCaptureTouchEventOutsidePrompt(true) .setOnHidePromptListener(new MaterialTapTargetPrompt.OnHidePromptListener() { @Override public void onHidePrompt(MotionEvent event, boolean tappedTarget) { } @Override public void onHidePromptComplete() { new MaterialTapTargetPrompt.Builder(RepoPagerView.this) .setTarget(forkRepo).setPrimaryText(R.string.fork) .setSecondaryText(R.string.fork_repo_hint) .setCaptureTouchEventOutsidePrompt(true).show(); } }).show(); } }).show(); } }
From source file:cz.maresmar.sfm.view.WithExtraFragment.java
@SuppressLint("ClickableViewAccessibility") @UiThread/* www .j a v a 2s .c om*/ private void inflateExtraFormat() { // Remove old extras from UI mExtraLinearLayout.removeAllViewsInLayout(); mExtraUiBindings = new EditText[mExtrasFormat.size()]; final LinearLayout.LayoutParams matchWrapParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); // For each extra int index = 0; for (ExtraFormat extraFormat : mExtrasFormat) { //noinspection ConstantConditions TextInputLayout textInputLayout = new TextInputLayout(getContext()); textInputLayout.setLayoutParams(matchWrapParams); textInputLayout.setHint(extraFormat.name); // If edit text extra if (extraFormat.valuesList.length == 0) { TextInputEditText editText = new TextInputEditText(getContext()); editText.setLayoutParams(matchWrapParams); mExtraUiBindings[index] = editText; textInputLayout.addView(editText); } else { // If extra with dropdown // Prepare adapter for values ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(), R.layout.support_simple_spinner_dropdown_item, extraFormat.valuesList); AutoCompleteTextView autoCompleteTextView = new AutoCompleteTextView(getContext()); autoCompleteTextView.setLayoutParams(matchWrapParams); autoCompleteTextView.setAdapter(adapter); // Some UI tweaks to make it look nice autoCompleteTextView.setKeyListener(null); autoCompleteTextView.setOnTouchListener((v, event) -> { ((AutoCompleteTextView) v).showDropDown(); return false; }); // Set default value autoCompleteTextView.setText(extraFormat.valuesList[0]); // setText disable other values so I have un-filter them adapter.getFilter().filter(null); mExtraUiBindings[index] = autoCompleteTextView; textInputLayout.addView(autoCompleteTextView); } mExtraLinearLayout.addView(textInputLayout); // Adds optimal extra description if (extraFormat.description != null) { TextView description = new TextView(getContext()); description.setText(extraFormat.description); TextViewCompat.setTextAppearance(description, R.style.StaticLabel); LinearLayout.LayoutParams descriptionLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); descriptionLayoutParams.setMargins(getResources().getDimensionPixelSize(R.dimen.content_margin), 0, 0, 0); description.setLayoutParams(descriptionLayoutParams); mExtraLinearLayout.addView(description); } index++; } }
From source file:com.fastaccess.ui.modules.repos.RepoPagerActivity.java
@Override public void onInitRepo() { hideProgress();/*from ww w.ja va 2 s . c om*/ if (getPresenter().getRepo() == null) { return; } setTaskName(getPresenter().getRepo().getFullName()); bottomNavigation.setOnMenuItemClickListener(getPresenter()); Repo repoModel = getPresenter().getRepo(); if (repoModel.getTopics() != null && !repoModel.getTopics().isEmpty()) { tagsIcon.setVisibility(View.VISIBLE); topicsList.setAdapter(new TopicsAdapter(repoModel.getTopics())); } else { topicsList.setVisibility(View.GONE); } onRepoPinned(AbstractPinnedRepos.isPinned(repoModel.getFullName())); wikiLayout.setVisibility(repoModel.isHasWiki() ? View.VISIBLE : View.GONE); pinText.setText(R.string.pin); detailsIcon.setVisibility(InputHelper.isEmpty(repoModel.getDescription()) ? View.GONE : View.VISIBLE); language.setVisibility(InputHelper.isEmpty(repoModel.getLanguage()) ? View.GONE : View.VISIBLE); if (!InputHelper.isEmpty(repoModel.getLanguage())) { language.setText(repoModel.getLanguage()); language.setTextColor(ColorsProvider.getColorAsColor(repoModel.getLanguage(), language.getContext())); } forkRepo.setText(numberFormat.format(repoModel.getForksCount())); starRepo.setText(numberFormat.format(repoModel.getStargazersCount())); watchRepo.setText(numberFormat.format(repoModel.getSubsCount())); if (repoModel.getOwner() != null) { avatarLayout.setUrl(repoModel.getOwner().getAvatarUrl(), repoModel.getOwner().getLogin(), repoModel.getOwner().isOrganizationType(), LinkParserHelper.isEnterprise(repoModel.getHtmlUrl())); } else if (repoModel.getOrganization() != null) { avatarLayout.setUrl(repoModel.getOrganization().getAvatarUrl(), repoModel.getOrganization().getLogin(), true, LinkParserHelper.isEnterprise(repoModel.getHtmlUrl())); } long repoSize = repoModel.getSize() > 0 ? (repoModel.getSize() * 1000) : repoModel.getSize(); date.setText(SpannableBuilder.builder().append(ParseDateFormat.getTimeAgo(repoModel.getPushedAt())) .append(" ,").append(" ").append(Formatter.formatFileSize(this, repoSize))); size.setVisibility(View.GONE); title.setText(repoModel.getFullName()); TextViewCompat.setTextAppearance(title, R.style.TextAppearance_AppCompat_Medium); title.setTextColor(ViewHelper.getPrimaryTextColor(this)); if (repoModel.getLicense() != null) { licenseLayout.setVisibility(View.VISIBLE); LicenseModel licenseModel = repoModel.getLicense(); license.setText(!InputHelper.isEmpty(licenseModel.getSpdxId()) ? licenseModel.getSpdxId() : licenseModel.getName()); } supportInvalidateOptionsMenu(); if (!PrefGetter.isRepoGuideShowed()) { } onRepoWatched(getPresenter().isWatched()); onRepoStarred(getPresenter().isStarred()); onRepoForked(getPresenter().isForked()); }
From source file:de.tobiasbielefeld.solitaire.games.Game.java
/** * Create a textView and add it to the given layout (game content). Used to add custom texts * to a game. This also sets the text apperance to AppCompat and the gravity to center. * The width and height is also measured, so you can use it directly. * * @param width The width to apply to the * @param layout he textView will be added to this layout * @param context Context to create view *///from w w w .java2 s . com protected void addTextViews(int count, int width, RelativeLayout layout, Context context) { for (int i = 0; i < count; i++) { TextView textView = new TextView(context); textView.setWidth(width); TextViewCompat.setTextAppearance(textView, R.style.TextAppearance_AppCompat); textView.setGravity(Gravity.CENTER); textView.setTextColor(Color.rgb(0, 0, 0)); layout.addView(textView); textView.measure(0, 0); textViews.add(textView); } }
From source file:org.buffer.android.buffertextinputlayout.BufferTextInputLayout.java
/** * Whether the error functionality is enabled or not in this layout. Enabling this * functionality before setting an error message via {@link #setError(CharSequence)}, will mean * that this layout will not change size when an error is displayed. * * @attr ref android.support.design.R.styleable#TextInputLayout_errorEnabled */// w w w.j a va 2s . c o m public void setErrorEnabled(boolean enabled) { if (errorEnabled != enabled) { if (errorView != null) { ViewCompat.animate(errorView).cancel(); } if (enabled) { errorView = new TextView(getContext()); boolean useDefaultColor = false; try { TextViewCompat.setTextAppearance(errorView, errorTextAppearance); if (Build.VERSION.SDK_INT >= 23 && errorView.getTextColors().getDefaultColor() == Color.MAGENTA) { // Caused by our theme not extending from Theme.Design*. On API 23 and // above, unresolved theme attrs result in MAGENTA rather than an exception. // Flag so that we use a decent default useDefaultColor = true; } } catch (Exception e) { // Caused by our theme not extending from Theme.Design*. Flag so that we use // a decent default useDefaultColor = true; } if (useDefaultColor) { // Probably caused by our theme not extending from Theme.Design*. Instead // we manually set something appropriate TextViewCompat.setTextAppearance(errorView, android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Caption); errorView.setTextColor( ContextCompat.getColor(getContext(), R.color.design_textinput_error_color_light)); } errorView.setVisibility(INVISIBLE); ViewCompat.setAccessibilityLiveRegion(errorView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE); addIndicator(errorView, 0); } else { errorShown = false; updateEditTextBackground(); removeIndicator(errorView); errorView = null; } errorEnabled = enabled; } }
From source file:android.support.design.widget.TextInputLayout.java
/** * Whether the error functionality is enabled or not in this layout. Enabling this * functionality before setting an error message via {@link #setError(CharSequence)}, will mean * that this layout will not change size when an error is displayed. * * @attr ref android.support.design.R.styleable#TextInputLayout_errorEnabled *//*from ww w . ja v a 2 s. c o m*/ public void setErrorEnabled(boolean enabled) { if (mErrorEnabled != enabled) { if (mErrorView != null) { ViewCompat.animate(mErrorView).cancel(); } if (enabled) { mErrorView = new AppCompatTextView(getContext()); mErrorView.setId(R.id.textinput_error); if (mTypeface != null) { mErrorView.setTypeface(mTypeface); } boolean useDefaultColor = false; try { TextViewCompat.setTextAppearance(mErrorView, mErrorTextAppearance); if (Build.VERSION.SDK_INT >= 23 && mErrorView.getTextColors().getDefaultColor() == Color.MAGENTA) { // Caused by our theme not extending from Theme.Design*. On API 23 and // above, unresolved theme attrs result in MAGENTA rather than an exception. // Flag so that we use a decent default useDefaultColor = true; } } catch (Exception e) { // Caused by our theme not extending from Theme.Design*. Flag so that we use // a decent default useDefaultColor = true; } if (useDefaultColor) { // Probably caused by our theme not extending from Theme.Design*. Instead // we manually set something appropriate TextViewCompat.setTextAppearance(mErrorView, android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Caption); mErrorView.setTextColor( ContextCompat.getColor(getContext(), R.color.design_textinput_error_color_light)); } mErrorView.setVisibility(INVISIBLE); ViewCompat.setAccessibilityLiveRegion(mErrorView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE); addIndicator(mErrorView, 0); } else { mErrorShown = false; updateEditTextBackground(); removeIndicator(mErrorView); mErrorView = null; } mErrorEnabled = enabled; } }
From source file:com.commonsware.cwac.crossport.design.widget.TextInputLayout.java
/** * Whether the error functionality is enabled or not in this layout. Enabling this * functionality before setting an error message via {@link #setError(CharSequence)}, will mean * that this layout will not change size when an error is displayed. * * @attr ref android.support.design.R.styleable#TextInputLayout_errorEnabled */// www .j a v a 2 s. c o m public void setErrorEnabled(boolean enabled) { if (mErrorEnabled != enabled) { if (mErrorView != null) { mErrorView.animate().cancel(); } if (enabled) { mErrorView = new TextView(getContext()); mErrorView.setId(R.id.textinput_error); if (mTypeface != null) { mErrorView.setTypeface(mTypeface); } boolean useDefaultColor = false; try { TextViewCompat.setTextAppearance(mErrorView, mErrorTextAppearance); if (Build.VERSION.SDK_INT >= 23 && mErrorView.getTextColors().getDefaultColor() == Color.MAGENTA) { // Caused by our theme not extending from Theme.Design*. On API 23 and // above, unresolved theme attrs result in MAGENTA rather than an exception. // Flag so that we use a decent default useDefaultColor = true; } } catch (Exception e) { // Caused by our theme not extending from Theme.Design*. Flag so that we use // a decent default useDefaultColor = true; } if (useDefaultColor) { // Probably caused by our theme not extending from Theme.Design*. Instead // we manually set something appropriate TextViewCompat.setTextAppearance(mErrorView, android.R.style.TextAppearance_Material_Caption); mErrorView.setTextColor( ContextCompat.getColor(getContext(), R.color.design_textinput_error_color_light)); } mErrorView.setVisibility(INVISIBLE); ViewCompat.setAccessibilityLiveRegion(mErrorView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE); addIndicator(mErrorView, 0); } else { mErrorShown = false; updateEditTextBackground(); removeIndicator(mErrorView); mErrorView = null; } mErrorEnabled = enabled; } }
From source file:android.support.design.widget.TextInputLayout.java
/** * Sets the text color and size for the error message from the specified * TextAppearance resource.// ww w.j av a 2 s.co m * * @attr ref android.support.design.R.styleable#TextInputLayout_errorTextAppearance */ public void setErrorTextAppearance(@StyleRes int resId) { mErrorTextAppearance = resId; if (mErrorView != null) { TextViewCompat.setTextAppearance(mErrorView, resId); } }