List of usage examples for android.widget TextView setTextColor
@android.view.RemotableViewMethod public void setTextColor(ColorStateList colors)
From source file:com.android.yijiang.kzx.widget.PagerSlidingTabStrip.java
private void changeToChild(int position) { if (tabCount == 0) { return;/*from www. ja va 2s .c o m*/ } // if(position!=mPageIndex){ // TextView childTextView=(TextView) tabsContainer.getChildAt(position); // TextView offsetTextView=(TextView) tabsContainer.getChildAt(mPageIndex); // //// childTextView.setTextColor(indicatorColor); //// offsetTextView.setTextColor(tabTextColor); // childTextView.setTextColor(Color.parseColor("#666666")); // childTextView.getPaint().setFakeBoldText(false); // offsetTextView.setTextColor(Color.parseColor("#666666")); // offsetTextView.getPaint().setFakeBoldText(false); // }else{ // TextView childTextView=(TextView) tabsContainer.getChildAt(position); //// childTextView.setTextColor(indicatorColor); // childTextView.setTextColor(Color.parseColor("#444444")); // childTextView.getPaint().setFakeBoldText(true); // } // for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); if (v instanceof TextView) { TextView tab = (TextView) v; if (position == i) { tab.setTextColor(Color.parseColor("#444444")); tab.setAlpha(1.0f); tab.getPaint().setFakeBoldText(true); } else { tab.setTextColor(Color.parseColor("#666666")); tab.setAlpha(0.7f); tab.getPaint().setFakeBoldText(false); } } } }
From source file:com.example.android.wearable.quiz.MainActivity.java
/** * Updates the given question based on whether it was answered correctly or not. * This involves changing the question's text color and changing the status text for it. */// w w w. ja v a 2s . co m public void updateQuestionStatus(int questionIndex, boolean questionCorrect) { LinearLayout questionStatusElement = (LinearLayout) questionsContainer.getChildAt(questionIndex); TextView questionText = (TextView) questionStatusElement.findViewById(R.id.question); TextView questionStatus = (TextView) questionStatusElement.findViewById(R.id.status); if (questionCorrect) { questionText.setTextColor(Color.GREEN); questionStatus.setText(R.string.question_correct); mNumCorrect++; } else { questionText.setTextColor(Color.RED); questionStatus.setText(R.string.question_incorrect); mNumIncorrect++; } }
From source file:com.astuetz.PagerSlidingTabStripExtendsBak.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); }//from w w w .j a v a 2 s .c o m } /* ------------------ 2016-4-12*/ if (mSelectedPosition == i) { tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectedTabTextSize); tab.setTextColor(selectedTabTextColor); } /* --------------------------- 2016-4-12*/ } } }
From source file:com.benefit.buy.library.viewpagerindicator.PagerSlidingTabStrip.java
@SuppressLint("NewApi") @Override//from ww w. ja v a 2 s. com protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || (tabCount == 0)) { return; } final int height = getHeight(); // draw underline rectPaint.setColor(underlineColor); canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint); // draw indicator line rectPaint.setColor(indicatorColor); // default: line below current tab View currentTab = tabsContainer.getChildAt(currentPosition); float lineLeft = currentTab.getLeft(); float lineRight = currentTab.getRight(); // if there is an offset, start interpolating left and right coordinates between current and next tab if ((currentPositionOffset > 0f) && (currentPosition < (tabCount - 1))) { View nextTab = tabsContainer.getChildAt(currentPosition + 1); final float nextTabLeft = nextTab.getLeft(); final float nextTabRight = nextTab.getRight(); lineLeft = ((currentPositionOffset * nextTabLeft) + ((1f - currentPositionOffset) * lineLeft)); lineRight = ((currentPositionOffset * nextTabRight) + ((1f - currentPositionOffset) * lineRight)); } if (currentTab.findViewById(R.id.img_click) != null) { int counts = tabsContainer.getChildCount(); View vNow = currentTab.findViewById(R.id.tab_name); ImageView imgNowOn = (ImageView) currentTab.findViewById(R.id.img_click); View tabViewNext; View vNext; ImageView imgNextOn; if ((currentPosition + 1) == counts) { tabViewNext = tabsContainer.getChildAt(0); vNext = tabViewNext.findViewById(R.id.tab_name); imgNextOn = (ImageView) tabViewNext.findViewById(R.id.img_click); } else { tabViewNext = tabsContainer.getChildAt(currentPosition + 1); vNext = tabViewNext.findViewById(R.id.tab_name); imgNextOn = (ImageView) tabViewNext.findViewById(R.id.img_click); } int colorTo = ToolColor.getChangeColor(80, 84, 98, 255, 0, 0, currentPositionOffset); int colorRe = ToolColor.getChangeColor(255, 0, 0, 80, 84, 98, currentPositionOffset); TextView tab = (TextView) vNext; TextView tab2 = (TextView) vNow; tab.setTextColor(colorTo); tab2.setTextColor(colorRe); if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { imgNextOn.setAlpha(currentPositionOffset); imgNowOn.setAlpha(1 - currentPositionOffset); } } else { } canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint); // draw divider dividerPaint.setColor(dividerColor); for (int i = 0; i < (tabCount - 1); i++) { View tab = tabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } }
From source file:cn.com.hgh.view.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor); if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); }//from w ww . j a v a 2 s. c o m } if (i == selectedPosition) { tab.setTextColor(selectedTabTextColor); } } } }
From source file:aierjun.com.aierjunlibrary.widget.tablayout.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); // v.setBackgroundDrawable(tabBackgroundDrawable); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor); if (i == 0) tab.setTextColor(tabchecktextcolor); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); }//from w w w .j a va2s.c o m } } } }
From source file:ca.zadrox.dota2esportticker.ui.BaseActivity.java
private void formatNavDrawerItem(View view, int itemId, boolean selected) { if (isSeparator(itemId)) { // not applicable return;/* w w w . j a v a 2 s.co m*/ } ImageView iconView = (ImageView) view.findViewById(R.id.icon); TextView titleView = (TextView) view.findViewById(R.id.title); // configure its appearance according to whether or not it's selected titleView.setTextColor(selected ? getResources().getColor(R.color.navdrawer_text_color_selected) : getResources().getColor(R.color.navdrawer_text_color)); iconView.setColorFilter(selected ? getResources().getColor(R.color.navdrawer_icon_tint_selected) : getResources().getColor(R.color.navdrawer_icon_tint)); }
From source file:cn.hollo.www.custom_view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title, int leftIcon) { TextView tab = new TextView(getContext()); tab.setText(title);//from w ww .ja v a 2s . c o m tab.setGravity(Gravity.CENTER); tab.setSingleLine(); if (tabTextColor != null) tab.setTextColor(tabTextColor); else tab.setTextColor(defaultTabTextColor); tab.setCompoundDrawablesWithIntrinsicBounds(leftIcon, 0, 0, 0); tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); addTab(position, tab); }
From source file:cn.hollo.www.custom_view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/*from w w w .j av a2s . c o m*/ tab.setGravity(Gravity.CENTER); tab.setSingleLine(); if (tabTextColor != null) tab.setTextColor(tabTextColor); else tab.setTextColor(defaultTabTextColor); tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); addTab(position, tab); }
From source file:com.android.widget.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//from w w w . j a va2s .c o m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setSingleLine(); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView.setTextColor(Color.WHITE); int hpadding = (int) (TAB_VIEW_HORIZONTAL_PADDING_DIPS * getResources().getDisplayMetrics().density); int vpadding = (int) (TAB_VIEW_VERTICAL_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(hpadding, vpadding, hpadding, vpadding); return textView; }