android.widget.TextView.setHintTextColor()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中android.widget.TextView.setHintTextColor()方法的一些代码示例,展示了TextView.setHintTextColor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setHintTextColor()方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setHintTextColor

TextView.setHintTextColor介绍

暂无

代码示例

代码示例来源:origin: rey5137/material

v.setHintTextColor(appearance.getColorStateList(attr));

代码示例来源:origin: rey5137/material

v.setHintTextColor(appearance.getColorStateList(attr));
v.setHintTextColor(a.getColorStateList(attr));

代码示例来源:origin: stackoverflow.com

SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
   SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
   searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
   int searchPlateId = searchView.getContext().getResources().getIdentifier("android:id/search_plate", null, null);
   searchView.findViewById(searchPlateId).setBackgroundResource(R.drawable.textfield_search_selected);
   int voiceSearchPlateId = searchView.getContext().getResources().getIdentifier("android:id/submit_area", null, null);
   searchView.findViewById(voiceSearchPlateId).setBackgroundResource(R.drawable.textfield_search_right_selected);
   // change hint color
   int searchTextViewId = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
   TextView searchTextView = (TextView) searchView.findViewById(searchTextViewId);
   searchTextView.setHintTextColor(getResources().getColor(R.color.light_grey));

代码示例来源:origin: flipkart-incubator/proteus

@Override
 public void setColor(T view, ColorStateList colors) {
  view.setHintTextColor(colors);
 }
});

代码示例来源:origin: flipkart-incubator/proteus

@Override
public void setColor(T view, int color) {
 view.setHintTextColor(color);
}

代码示例来源:origin: LightSun/data-mediator

@Override
  protected void apply(Property prop, View view, Object newValue) {
    ((TextView)view).setHintTextColor((Integer) newValue);
  }
}

代码示例来源:origin: stackoverflow.com

int searchHintBtnId = searchView.getContext().getResources()
         .getIdentifier("android:id/search_mag_icon", null, null);
  int hintTextId = searchView.getContext()
         .getResources()
         .getIdentifier("android:id/search_src_text", null, null);
     int closeBtnId = searchView.getContext()
         .getResources()
         .getIdentifier("android:id/search_close_btn", null, null);
     // Set the search plate color to white
     int searchPlateId = getResources().getIdentifier("android:id/search_plate", null, null);
     View view = searchView.findViewById(searchPlateId);
     view.setBackgroundResource(R.drawable.search_plate);
     ImageView closeIcon = (ImageView) searchView.findViewById(closeBtnId);
     closeIcon.setImageResource(R.drawable.close);
     ImageView searchHintIcon = (ImageView) searchView.findViewById(searchHintBtnId);
     searchHintIcon.setImageResource(R.drawable.search);
     TextView textView = (TextView) searchView.findViewById(hintTextId);
     textView.setTextColor(getResources().getColor(R.color.search_text_color));
     textView.setHintTextColor(getResources().getColor(R.color.search_hint_text_color));

代码示例来源:origin: stackoverflow.com

// Get textview id of search widget
int id =  searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
TextView textView = (TextView) searchView.findViewById(id);

// Set search text color
textView.setTextColor(Color.WHITE);

// Set search hints color
textView.setHintTextColor(Color.GRAY);

代码示例来源:origin: stackoverflow.com

int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
TextView textView = (TextView) searchView.findViewById(id);
textView.setTextColor(Color.WHITE);
textView.setHintTextColor(Color.WHITE);

代码示例来源:origin: LightSun/data-mediator

@Override
  protected void apply(Property prop, View view, Object newValue) {
    ColorStateList list = view.getResources().getColorStateList((Integer) newValue);
    ((TextView)view).setHintTextColor(list);
  }
}

代码示例来源:origin: uccmawei/ColorView

private void updateTextColorHint() {
  int[] colors = {mTextColorHintUnable, mTextColorHintPressed, mTextColorHintSelected, mTextColorHintChecked, mTextColorHintNormal, mTextColorHintNormal};
  mView.setHintTextColor(new ColorStateList(Constant.STATE_ARRAY, colors));
}

代码示例来源:origin: stackoverflow.com

// Setting up the TextView of searchView suggestions drop down list
for (TextView textView : findChildrenByClass(mSearchView, TextView.class)) {
   textView.setHint("Type a word");
   textView.setTextColor(Color.rgb(255, 255, 255));
   textView.setHintTextColor(Color.argb(128, 255, 255, 255));
}

代码示例来源:origin: qqliu10u/QSkinLoader

@Override
  public void apply(View view, SkinAttr skinAttr, IResourceManager resourceManager) {
    if (null == view
        || null == skinAttr
        || !(SkinAttrName.TEXT_COLOR_HINT.equals(skinAttr.mAttrName))) {
      return;
    }

    if (!(view instanceof TextView)) {
      return;
    }

    TextView tv = (TextView) view;
    if (SkinConstant.RES_TYPE_NAME_COLOR.equals(skinAttr.mAttrValueTypeName)) {
      //按照ColorStateList引用来解析;
      //context.getResources().getColor()方法可以取纯颜色,也可以取ColorStateList引用内的颜色,
      //如果取的是ColorStateList,则取其中默认颜色;
      //同时,context.getResources().getColorStateList()方法也可以取纯颜色生成一个ColorStateList
      ColorStateList textHintColor = resourceManager.getColorStateList(
          skinAttr.mAttrValueRefId, skinAttr.mAttrValueRefName);
      tv.setHintTextColor(textHintColor);
    }
  }
}

代码示例来源:origin: xuancao/DynamicSkin

@Override
  public void process(@NonNull Context context, @Nullable String key, @Nullable View target, @Nullable Integer tintColor) {
    if (target == null || tintColor == null) return;
    final Class<?> cls = target.getClass();
    try {
      final Field mSearchSrcTextViewField = cls.getDeclaredField("mSearchSrcTextView");
      mSearchSrcTextViewField.setAccessible(true);
      final TextView mSearchSrcTextView = (TextView) mSearchSrcTextViewField.get(target);
      mSearchSrcTextView.setTextColor(tintColor);
      mSearchSrcTextView.setHintTextColor(Util.adjustAlpha(tintColor, 0.5f));

      Field field = cls.getDeclaredField("mSearchButton");
      tintImageView(target, field, tintColor);
      field = cls.getDeclaredField("mGoButton");
      tintImageView(target, field, tintColor);
      field = cls.getDeclaredField("mCloseButton");
      tintImageView(target, field, tintColor);
      field = cls.getDeclaredField("mVoiceButton");
      tintImageView(target, field, tintColor);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

代码示例来源:origin: googlesamples/android-unsplash

@Override
public void onAnimationEnd(Animator animation) {
  textView.getOverlay().remove(drawable);
  textView.setTextColor(textColors);
  textView.setHintTextColor(hintColors);
  textView.setHighlightColor(highlightColor);
  textView.setLinkTextColor(linkColors);
}

代码示例来源:origin: DroidsOnRoids/Workcation

@Override
public void onAnimationEnd(Animator animation) {
  textView.getOverlay().remove(drawable);
  textView.setTextColor(textColors);
  textView.setHintTextColor(hintColors);
  textView.setHighlightColor(highlightColor);
  textView.setLinkTextColor(linkColors);
}

代码示例来源:origin: garretyoder/app-theme-engine

@Override
  public void process(@NonNull Context context, @Nullable String key, @NonNull View view, @NonNull String suffix) {
    final TextView tv = (TextView) view;
    final ColorResult result = getColorFromSuffix(context, key, view, suffix);
    if (result == null) return;

    if (mHintMode)
      result.adjustAlpha(0.5f);

    final ColorStateList sl = getTextSelector(result.getColor(), view, false);
    if (mLinkMode) {
      tv.setLinkTextColor(sl);
    } else if (mHintMode) {
      tv.setHintTextColor(sl);
      // Sets parent TextInputLayout hint color
      if (view.getParent() != null && view.getParent() instanceof TextInputLayout) {
        final TextInputLayout til = (TextInputLayout) view.getParent();
        TextInputLayoutUtil.setHint(til, result.getColor());
      }
    } else {
      tv.setTextColor(sl);
    }
  }
}

代码示例来源:origin: stackoverflow.com

public class MainActivity extends FragmentActivity{
  static SearchView searchView;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    searchView = (SearchView)findViewById(R.id.searchView1);
    searchView.setQueryHint("Type Word...");
    int searchPlateId = searchView.getContext().getResources().getIdentifier("android:id/search_plate", null, null);
    View searchPlate = searchView.findViewById(searchPlateId);
    if (searchPlate!=null) {
      searchPlate.setBackgroundColor(Color.WHITE);
      int searchTextId = searchPlate.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
      TextView searchText = (TextView) searchPlate.findViewById(searchTextId);
      if (searchText!=null) {
        searchText.setTextColor(Color.DKGRAY);
        searchText.setHintTextColor(Color.LTGRAY);

        //This is what you want?
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        searchView.getRootView();//Notice that i change this
        searchView.setSearchableInfo(
        searchManager.getSearchableInfo(getComponentName()));
      }
    }       
}

代码示例来源:origin: WeAreFairphone/FP2-Launcher

private void colorSearchArea() {
  mSearchView.setBackgroundColor(Color.WHITE);
  int searchAreaId = mSearchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
  TextView textView = (TextView) mSearchView.findViewById(searchAreaId);
  textView.setTextColor(mLauncher.getResources().getColor(R.color.blue));
  textView.setHintTextColor(mLauncher.getResources().getColor(R.color.blue_alpha_50));
  textView.setBackgroundColor(Color.WHITE);
  int searchGlassId = mLauncher.getResources().getIdentifier("android:id/search_mag_icon", null, null);
  ImageView searchGlassIcon = (ImageView) mSearchView.findViewById(searchGlassId);
  if (searchGlassIcon != null) {
    searchGlassIcon.setScaleType(ImageView.ScaleType.CENTER);
    searchGlassIcon.setColorFilter(Color.rgb(42, 168, 224));
    searchGlassIcon.setImageResource(R.drawable.ic_all_apps_search);
  }
  int closeId = mLauncher.getResources().getIdentifier("android:id/search_close_btn", null, null);
  ImageView closeBtn = (ImageView) mSearchView.findViewById(closeId);
  if (closeBtn != null) {
    closeBtn.setColorFilter(mLauncher.getResources().getColor(R.color.blue));
    closeBtn.setBackgroundColor(Color.WHITE);
  }
  int searchPlateId = mLauncher.getResources().getIdentifier("android:id/search_plate", null, null);
  LinearLayout searchPlateIcon = (LinearLayout) mSearchView.findViewById(searchPlateId);
  if (searchPlateIcon != null)
    searchPlateIcon.setBackgroundColor(mLauncher.getResources().getColor(R.color.blue));
}

代码示例来源:origin: wutongke/AndroidSkinAnimator

public void applySkin() {
    mTextColorResId = checkResourceId(mTextColorResId);
    if (mTextColorResId != INVALID_ID) {
      ColorStateList color = SkinCompatResources.getInstance().getColorStateList(mTextColorResId);
      mView.setTextColor(color);
    }
    mTextColorHintResId = checkResourceId(mTextColorHintResId);
    if (mTextColorHintResId != INVALID_ID) {
      ColorStateList color = SkinCompatResources.getInstance().getColorStateList(mTextColorHintResId);
      mView.setHintTextColor(color);
    }
  }
}

相关文章

微信公众号

最新文章

更多

TextView类方法