Java Code Examples for android.support.v7.widget.AppCompatTextView#setTextColor()

The following examples show how to use android.support.v7.widget.AppCompatTextView#setTextColor() . 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: DotLayout.java    From nono-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void initUI() {
    LinearLayout linearLayout=new LinearLayout(getContext());
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    textView=new AppCompatTextView(getContext());
    int size=(int)(getResources().getDisplayMetrics().density*32);
    LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(size,size);
    //lp.gravity=Gravity.CENTER_VERTICAL;
    textView.setLayoutParams(lp);
    textView.setText("·");
    textView.setTextColor(0xff000000);
    textView.setTextAppearance(getContext(),R.style.DotTextAppearance);
    textView.setGravity(Gravity.CENTER);
    editText=new BaseRichEditText(getContext());
    editText.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT,1.0f));
    linearLayout.addView(textView);
    linearLayout.addView(editText);
    this.addView(linearLayout);
}
 
Example 2
Source File: NumericLayout.java    From nono-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void initUI() {
    LinearLayout linearLayout=new LinearLayout(getContext());
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    textView=new AppCompatTextView(getContext());
    int size=(int)(getResources().getDisplayMetrics().density*32);
    LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(size,size);
    //lp.gravity= Gravity.CENTER_VERTICAL;
    textView.setLayoutParams(lp);
    textView.setTextColor(0xff000000);
    textView.setGravity(Gravity.CENTER);
    editText=new BaseRichEditText(getContext());
    editText.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT,1.0f));
    linearLayout.addView(textView);
    linearLayout.addView(editText);
    this.addView(linearLayout);
}
 
Example 3
Source File: IndexableLayout.java    From IndexableRecyclerView with Apache License 2.0 6 votes vote down vote up
private void initMDOverlay(int color) {
    mMDOverlay = new AppCompatTextView(mContext);
    mMDOverlay.setBackgroundResource(R.drawable.indexable_bg_md_overlay);
    ((AppCompatTextView) mMDOverlay).setSupportBackgroundTintList(ColorStateList.valueOf(color));
    mMDOverlay.setSingleLine();
    mMDOverlay.setTextColor(Color.WHITE);
    mMDOverlay.setTextSize(38);
    mMDOverlay.setGravity(Gravity.CENTER);
    int size = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 72, getResources().getDisplayMetrics());
    LayoutParams params = new LayoutParams(size, size);
    params.rightMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 33, getResources().getDisplayMetrics());
    params.gravity = Gravity.END;
    mMDOverlay.setLayoutParams(params);
    mMDOverlay.setVisibility(INVISIBLE);

    addView(mMDOverlay);
}
 
Example 4
Source File: DownloadManagerResolver.java    From FaceSlim with GNU General Public License v2.0 6 votes vote down vote up
private static AlertDialog createDialog(final Context context) {
    AppCompatTextView messageTextView = new AppCompatTextView(context);
    messageTextView.setTextSize(16f);
    messageTextView.setText(context.getString(R.string.download_manager_disabled));
    messageTextView.setPadding(50, 50, 50, 0);
    messageTextView.setTextColor(ContextCompat.getColor(context, R.color.black));
    return new AlertDialog.Builder(context)
            .setView(messageTextView)
            .setPositiveButton("ok", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    enableDownloadManager(context);
                }
            })
            .setCancelable(false)
            .create();
}
 
Example 5
Source File: BaseBottomDelegate.java    From FastWaiMai with MIT License 5 votes vote down vote up
@Override
public void onBindView(@Nullable Bundle savedInstanceState, @NonNull View view) {
    final int size = ITEMS.size();
    for(int i = 0; i < size; i++){
        LayoutInflater.from(getContext()).inflate(R.layout.bottom_item_icon_text_layout, mBottomBar);
        final RelativeLayout item = (RelativeLayout) mBottomBar.getChildAt(i);
        //设置每一个item的点击事件
        item.setTag(i);
        item.setOnClickListener(this);
        //图标
        final IconTextView itemIcon = (IconTextView) item.getChildAt(0);
        //文字
        final AppCompatTextView itemTitle = (AppCompatTextView) item.getChildAt(1);

        final BottomTabBean bean = TAB_BEANS.get(i);
        //初始化数据
        itemIcon.setText(bean.getIcon());
        itemTitle.setText(bean.getTitle());

        if (i == mIndexDelegate) {
            itemIcon.setTextColor(mClickedColor);
            itemTitle.setTextColor(mClickedColor);
        }
    }
    final ISupportFragment[] delegateArray = ITEM_DELEGATES.toArray(new ISupportFragment[size]);


    //加载多个同级根Fragment,类似Wechat, QQ主页的场景
    getSupportDelegate().loadMultipleRootFragment(R.id.bottom_bar_delegate_container, mIndexDelegate, delegateArray);
}
 
Example 6
Source File: BaseBottomDelegate.java    From FastWaiMai with MIT License 5 votes vote down vote up
@Override
public void onClick(View v) {
    final int tag = (int) v.getTag();
    resetColor();
    final RelativeLayout item = (RelativeLayout) v;
    //切换颜色
    final IconTextView itemIcon = (IconTextView) item.getChildAt(0);
    itemIcon.setTextColor(mClickedColor);
    final AppCompatTextView itemTitle = (AppCompatTextView) item.getChildAt(1);
    itemTitle.setTextColor(mClickedColor);
    //切换Fragment  showFragment hideFragment
    getSupportDelegate().showHideFragment(ITEM_DELEGATES.get(tag), ITEM_DELEGATES.get(mCurrentDelegate));

    mCurrentDelegate = tag;
}
 
Example 7
Source File: BaseBottomDelegate.java    From FastWaiMai with MIT License 5 votes vote down vote up
private void resetColor(){
    final int count = mBottomBar.getChildCount();
    for(int i = 0; i < count; i++){
        final RelativeLayout item = (RelativeLayout) mBottomBar.getChildAt(i);

        final IconTextView itemIcon = (IconTextView) item.getChildAt(0);
        itemIcon.setTextColor(Color.GRAY);

        final AppCompatTextView itemTitle = (AppCompatTextView) item.getChildAt(1);
        itemTitle.setTextColor(Color.GRAY);
    }
}
 
Example 8
Source File: IndexableStickyListView.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
private void initRightOverlayTextView(int color) {
    mTvRightOverlay = new AppCompatTextView(mContext);
    mTvRightOverlay.setBackgroundResource(R.drawable.bg_right_overlay);
    mTvRightOverlay.setSupportBackgroundTintList(ColorStateList.valueOf(color));
    mTvRightOverlay.setTextColor(Color.WHITE);
    mTvRightOverlay.setTextSize(38);
    mTvRightOverlay.setGravity(Gravity.CENTER);
    int size = IndexBar.dp2px(mContext, 72);
    LayoutParams params = new LayoutParams(size, size);
    params.rightMargin = IndexBar.dp2px(mContext, 33);
    params.gravity = Gravity.RIGHT;
    mTvRightOverlay.setLayoutParams(params);
    mTvRightOverlay.setVisibility(INVISIBLE);
}
 
Example 9
Source File: SettingsSpinnerAdapter.java    From Puff-Android with MIT License 5 votes vote down vote up
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
    AppCompatTextView ret = new AppCompatTextView(parent.getContext());
    ret.setText(displayText[position]);
    ret.setTextSize(16);
    ret.setPadding(0, 10, 0, 10);
    ret.setTextColor(Color.BLACK);
    return ret;
}
 
Example 10
Source File: SettingsSpinnerAdapter.java    From Puff-Android with MIT License 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    AppCompatTextView ret = new AppCompatTextView(parent.getContext());
    ret.setText(displayText[position]);
    ret.setTextSize(16);
    ret.setPadding(0, 10, 0, 10);
    ret.setTextColor(Color.BLACK);
    return ret;
}
 
Example 11
Source File: SortRecyclerAdapter.java    From FastWaiMai with MIT License 4 votes vote down vote up
@Override
protected void convert(final MultipleViewHolder holder, final MultipleItemEntity entity) {
	switch (holder.getItemViewType()){
		case ItemType.VERTICAL_MENU_LIST:
			final String text = entity.getField(MultipleFields.TEXT);
			final Boolean isClicked = entity.getField(MultipleFields.TAG);
			View viewLine = holder.getView(R.id.view_line);
			final AppCompatTextView textView =  holder.getView(R.id.tv_vertical_item_name);
			final View itemView = holder.itemView;
			itemView.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					//类别的点击  getAdapterPosition:从0开始
					final int currentPosition = holder.getAdapterPosition();
					if(mPrePosition != currentPosition){
						//还原上次状态
						getData().get(mPrePosition).setField(MultipleFields.TAG, false);
						notifyItemChanged(mPrePosition);


						//更新item状态
						entity.setField(MultipleFields.TAG, true);
						notifyItemChanged(currentPosition);

						mPrePosition = currentPosition;

						//点击类别 内容栏跳转
						final Integer categoryId = getData().get(currentPosition).getField(MultipleFields.ID);
						showContent(categoryId);

					}

				}
			});
			if(isClicked){
				viewLine.setVisibility(View.VISIBLE);
				textView.setTextColor(ContextCompat.getColor(mContext, R.color.app_main));
				viewLine.setBackgroundColor(ContextCompat.getColor(mContext, R.color.app_main));
				itemView.setBackgroundColor(Color.WHITE);
			}else {
				viewLine.setVisibility(View.INVISIBLE);
				textView.setTextColor(ContextCompat.getColor(mContext, R.color.we_chat_black));
				viewLine.setBackgroundColor(ContextCompat.getColor(mContext, R.color.item_background));
			}

			holder.setText(R.id.tv_vertical_item_name,text);
	}
}
 
Example 12
Source File: CircularTabLayoutAdapter.java    From CircularViewPager with MIT License 4 votes vote down vote up
final void update(CircularTabLayout.Tab tab) {
    ColorStateList tabTextColors = tab.getTextColorStateList() == null ? mTabTextColors : tab.getTextColorStateList();

    mTab = tab;
    View custom = tab.getCustomView();
    if (custom != null) {
        ViewParent icon = custom.getParent();
        if (icon != this) {
            if (icon != null) {
                ((ViewGroup) icon).removeView(custom);
            }
            addView(custom);
        }

        mCustomView = custom;
        if (mTextView != null) {
            mTextView.setVisibility(View.GONE);
        }

        if (mIconView != null) {
            mIconView.setVisibility(View.GONE);
            mIconView.setImageDrawable(null);
        }
    } else {
        if (mCustomView != null) {
            removeView(mCustomView);
            mCustomView = null;
        }

        Drawable icon1 = tab.getIcon();
        CharSequence text = tab.getText();
        if (icon1 != null) {
            if (mIconView == null) {
                ImageView hasText = new ImageView(getContext());
                LayoutParams textView = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
                textView.gravity = Gravity.CENTER_VERTICAL;
                hasText.setLayoutParams(textView);
                addView(hasText, 0);
                mIconView = hasText;
            }

            mIconView.setImageDrawable(icon1);
            mIconView.setVisibility(View.VISIBLE);
        } else if (mIconView != null) {
            mIconView.setVisibility(View.GONE);
            mIconView.setImageDrawable(null);
        }

        boolean hasText1 = !TextUtils.isEmpty(text);
        if (hasText1) {
            if (mTextView == null) {
                AppCompatTextView textView1 = new AppCompatTextView(getContext());
                textView1.setTextAppearance(getContext(), mTabTextAppearance);
                if (mTabTextSize != -1) {
                    textView1.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabTextSize);
                }
                textView1.setMaxLines(MAX_TAB_TEXT_LINES);
                textView1.setEllipsize(TextUtils.TruncateAt.END);
                textView1.setGravity(Gravity.CENTER);
                if (tabTextColors != null) {
                    textView1.setTextColor(tabTextColors);
                }
                addView(textView1, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
                mTextView = textView1;
            }
            mTextView.setText(text);
            mTextView.setContentDescription(tab.getContentDescription());
            mTextView.setVisibility(View.VISIBLE);
        } else if (mTextView != null) {
            mTextView.setVisibility(View.GONE);
            mTextView.setText(null);
        }

        if (mIconView != null) {
            mIconView.setContentDescription(tab.getContentDescription());
        }

        if (!hasText1 && !TextUtils.isEmpty(tab.getContentDescription())) {
            setOnLongClickListener(this);
            setLongClickable(true);
        } else {
            setOnLongClickListener(null);
            setLongClickable(false);
        }
    }
}
 
Example 13
Source File: CircularTabLayoutAdapter.java    From CircularViewPager with MIT License 4 votes vote down vote up
final void update(CircularTabLayout.Tab tab) {
    ColorStateList tabTextColors = tab.getTextColorStateList() == null ? mTabTextColors : tab.getTextColorStateList();

    mTab = tab;
    View custom = tab.getCustomView();
    if (custom != null) {
        ViewParent icon = custom.getParent();
        if (icon != this) {
            if (icon != null) {
                ((ViewGroup) icon).removeView(custom);
            }
            addView(custom);
        }

        mCustomView = custom;
        if (mTextView != null) {
            mTextView.setVisibility(View.GONE);
        }

        if (mIconView != null) {
            mIconView.setVisibility(View.GONE);
            mIconView.setImageDrawable(null);
        }
    } else {
        if (mCustomView != null) {
            removeView(mCustomView);
            mCustomView = null;
        }

        Drawable icon1 = tab.getIcon();
        CharSequence text = tab.getText();
        if (icon1 != null) {
            if (mIconView == null) {
                ImageView hasText = new ImageView(getContext());
                LayoutParams textView = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
                textView.gravity = Gravity.CENTER_VERTICAL;
                hasText.setLayoutParams(textView);
                addView(hasText, 0);
                mIconView = hasText;
            }

            mIconView.setImageDrawable(icon1);
            mIconView.setVisibility(View.VISIBLE);
        } else if (mIconView != null) {
            mIconView.setVisibility(View.GONE);
            mIconView.setImageDrawable(null);
        }

        boolean hasText1 = !TextUtils.isEmpty(text);
        if (hasText1) {
            if (mTextView == null) {
                AppCompatTextView textView1 = new AppCompatTextView(getContext());
                textView1.setTextAppearance(getContext(), mTabTextAppearance);
                if (mTabTextSize != -1) {
                    textView1.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabTextSize);
                }
                textView1.setMaxLines(MAX_TAB_TEXT_LINES);
                textView1.setEllipsize(TextUtils.TruncateAt.END);
                textView1.setGravity(Gravity.CENTER);
                if (tabTextColors != null) {
                    textView1.setTextColor(tabTextColors);
                }
                addView(textView1, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
                mTextView = textView1;
            }
            mTextView.setText(text);
            mTextView.setContentDescription(tab.getContentDescription());
            mTextView.setVisibility(View.VISIBLE);
        } else if (mTextView != null) {
            mTextView.setVisibility(View.GONE);
            mTextView.setText(null);
        }

        if (mIconView != null) {
            mIconView.setContentDescription(tab.getContentDescription());
        }

        if (!hasText1 && !TextUtils.isEmpty(tab.getContentDescription())) {
            setOnLongClickListener(this);
            setLongClickable(true);
        } else {
            setOnLongClickListener(null);
            setLongClickable(false);
        }
    }
}