当前位置: 首页>>代码示例>>Java>>正文


Java TextViewCompat.setCompoundDrawablesRelative方法代码示例

本文整理汇总了Java中android.support.v4.widget.TextViewCompat.setCompoundDrawablesRelative方法的典型用法代码示例。如果您正苦于以下问题:Java TextViewCompat.setCompoundDrawablesRelative方法的具体用法?Java TextViewCompat.setCompoundDrawablesRelative怎么用?Java TextViewCompat.setCompoundDrawablesRelative使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.widget.TextViewCompat的用法示例。


在下文中一共展示了TextViewCompat.setCompoundDrawablesRelative方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setSelected

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
@Override
public void setSelected(boolean selected) {
    if (selected){
        TextViewCompat.setCompoundDrawablesRelative(
                this,
                null,
                selectDrawable,
                null,
                null
        );
        this.setTextColor(selectColor);
    }else {
        TextViewCompat.setCompoundDrawablesRelative(
                this,
                null,
                normalDrawable,
                null,
                null
        );
        this.setTextColor(normalColor);
    }
    super.setSelected(selected);
}
 
开发者ID:xsingHu,项目名称:xs-android-architecture,代码行数:24,代码来源:SelectTextView.java

示例2: testMaintainsStartEndCompoundDrawables

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
@UiThreadTest
@Test
public void testMaintainsStartEndCompoundDrawables() throws Throwable {
  final Activity activity = activityTestRule.getActivity();

  // Set a known set of test compound drawables on the EditText
  final Drawable start = new ColorDrawable(Color.RED);
  final Drawable top = new ColorDrawable(Color.GREEN);
  final Drawable end = new ColorDrawable(Color.BLUE);
  final Drawable bottom = new ColorDrawable(Color.BLACK);

  final TextInputEditText editText = new TextInputEditText(activity);
  TextViewCompat.setCompoundDrawablesRelative(editText, start, top, end, bottom);

  // Now add the EditText to a TextInputLayout
  TextInputLayout til = activity.findViewById(R.id.textinput_noedittext);
  til.addView(editText);

  // Finally assert that all of the drawables are untouched
  final Drawable[] compoundDrawables = TextViewCompat.getCompoundDrawablesRelative(editText);
  assertSame(start, compoundDrawables[0]);
  assertSame(top, compoundDrawables[1]);
  assertSame(end, compoundDrawables[2]);
  assertSame(bottom, compoundDrawables[3]);
}
 
开发者ID:material-components,项目名称:material-components-android,代码行数:26,代码来源:TextInputLayoutTest.java

示例3: setIcon

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
@Override
public void setIcon(Drawable icon) {
  if (icon != null) {
    if (hasIconTintList) {
      Drawable.ConstantState state = icon.getConstantState();
      icon = DrawableCompat.wrap(state == null ? icon : state.newDrawable()).mutate();
      DrawableCompat.setTintList(icon, iconTintList);
    }
    icon.setBounds(0, 0, iconSize, iconSize);
  } else if (needsEmptyIcon) {
    if (emptyDrawable == null) {
      emptyDrawable =
          ResourcesCompat.getDrawable(
              getResources(), R.drawable.navigation_empty_icon, getContext().getTheme());
      if (emptyDrawable != null) {
        emptyDrawable.setBounds(0, 0, iconSize, iconSize);
      }
    }
    icon = emptyDrawable;
  }
  TextViewCompat.setCompoundDrawablesRelative(textView, icon, null, null, null);
}
 
开发者ID:material-components,项目名称:material-components-android,代码行数:23,代码来源:NavigationMenuItemView.java

示例4: getDropDownView

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
@Override
@NonNull
public View getDropDownView(int position, @Nullable View convertView,
        @NonNull ViewGroup parent) {
    TextView textView = initTextView(position, convertView, parent);
    if (textView != convertView) {
        Drawable icon = createIcon();
        StateListDrawable statefulIcon = new StateListDrawable();
        statefulIcon.setBounds(icon.getBounds());
        statefulIcon.addState(ACTIVATED_STATE_SET, icon);
        TextViewCompat.setCompoundDrawablesRelative(
                textView, statefulIcon, null, null, null);
    }
    ViewGroup.LayoutParams layoutParams = textView.getLayoutParams();
    if (layoutParams.height == ViewGroup.LayoutParams.MATCH_PARENT) {
        layoutParams.height = spinner.getHeight() -
                spinner.getPaddingTop() - spinner.getPaddingBottom();
    }
    return textView;
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:21,代码来源:DiscussionPostsSpinnerAdapter.java

示例5: setIcon

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
@Override
public void setIcon(Drawable icon) {
  if (icon != null) {
    if (mHasIconTintList) {
      Drawable.ConstantState state = icon.getConstantState();
      icon = DrawableCompat.wrap(state == null ? icon : state.newDrawable()).mutate();
      DrawableCompat.setTintList(icon, mIconTintList);
    }
    icon.setBounds(0, 0, mIconSize, mIconSize);
  } else if (mNeedsEmptyIcon) {
    if (mEmptyDrawable == null) {
      mEmptyDrawable =
          ResourcesCompat.getDrawable(
              getResources(), R.drawable.navigation_empty_icon, getContext().getTheme());
      if (mEmptyDrawable != null) {
        mEmptyDrawable.setBounds(0, 0, mIconSize, mIconSize);
      }
    }
    icon = mEmptyDrawable;
  }
  TextViewCompat.setCompoundDrawablesRelative(mTextView, icon, null, null, null);
}
 
开发者ID:google,项目名称:iosched,代码行数:23,代码来源:NavigationMenuItemView.java

示例6: setupTextColor

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
public static void setupTextColor(TextView view, AttributeSet attrs) {
    StyledAttributesHelper r = StyledAttributesHelper.obtainStyledAttributes(view.getContext(), attrs, THEME_ATTRS);
    int colorResId = r.getResourceId(android.R.attr.textColor, 0);
    if (colorResId == 0) {
        int appearanceRes = r.getResourceId(android.R.attr.textAppearance, 0);
        if (appearanceRes != 0) {
            StyledAttributesHelper ta = StyledAttributesHelper.obtainStyledAttributes(
                    view.getContext(), appearanceRes, new int[] { android.R.attr.textColor });
            colorResId = ta.getResourceId(android.R.attr.textColor, 0);
            ta.recycle();
        }
    }
    if (colorResId == R.color.colorPrimary)
        view.setTextColor(ThemeHelper.getPrimaryColor(view.getContext()));
    else if (colorResId == R.color.colorAccent)
        view.setTextColor(ThemeHelper.getAccentColor(view.getContext()));
    colorResId = r.getResourceId(android.R.attr.textColorLink, 0);
    if (colorResId == R.color.colorAccent)
        view.setLinkTextColor(ThemeHelper.getAccentColor(view.getContext()));

    Drawable[] drawables = TextViewCompat.getCompoundDrawablesRelative(view);
    boolean hasChange = false;
    for (int i = 0; i < 4; i++) {
        Drawable newDrawable = tintDrawable(view.getContext(), r, DRAWABLE_ATTRS[i], drawables[i]);
        if (newDrawable != drawables[i]) {
            drawables[i] = newDrawable;
            hasChange = true;
        }
    }
    if (hasChange)
        TextViewCompat.setCompoundDrawablesRelative(view, drawables[0], drawables[1], drawables[2], drawables[3]);
    r.recycle();
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:34,代码来源:ThemedTextView.java

示例7: setIcon

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
public void setIcon(Drawable icon) {
    if (icon != null) {
        ConstantState state = icon.getConstantState();
        if (state != null) {
            icon = state.newDrawable();
        }
        icon = DrawableCompat.wrap(icon).mutate();
        icon.setBounds(0, 0, this.mIconSize, this.mIconSize);
        DrawableCompat.setTintList(icon, this.mIconTintList);
    }
    TextViewCompat.setCompoundDrawablesRelative(this.mTextView, icon, null, null, null);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:13,代码来源:NavigationMenuItemView.java

示例8: getView

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LvMenuItem item = mItems.get(position);
    switch (item.type) {
        case LvMenuItem.TYPE_NORMAL:
            if (convertView == null) {
                convertView = mInflater.inflate(R.layout.listitem_drawer_menu_item, parent,
                        false);
            }
            TextView itemView = (TextView) convertView;
            itemView.setText(item.name);
            Drawable icon = mContext.getResources().getDrawable(item.icon);
            setIconColor(icon);
            if (icon != null) {
                icon.setBounds(0, 0, mIconSize, mIconSize);
                TextViewCompat.setCompoundDrawablesRelative(itemView, icon, null, null, null);
            }

            break;
        case LvMenuItem.TYPE_NO_ICON:
            if (convertView == null) {
                convertView = mInflater.inflate(R.layout.listitem_drawer_subheader,
                        parent, false);
            }
            TextView subHeader = (TextView) convertView;
            subHeader.setText(item.name);
            break;
        case LvMenuItem.TYPE_SEPARATOR:
            if (convertView == null) {
                convertView = mInflater.inflate(R.layout.listitem_drawer_seperator,
                        parent, false);
            }
            break;
    }

    return convertView;
}
 
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:38,代码来源:DrawerListAdapter.java

示例9: setCompoundDrawablesRelative

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
/** Sets compound drawables on {@link TextView} */
public static ViewAction setCompoundDrawablesRelative(
    final @Nullable Drawable start,
    final @Nullable Drawable top,
    final @Nullable Drawable end,
    final @Nullable Drawable bottom) {
  return new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
      return isAssignableFrom(TextView.class);
    }

    @Override
    public String getDescription() {
      return "TextView set compound drawables relative";
    }

    @Override
    public void perform(UiController uiController, View view) {
      uiController.loopMainThreadUntilIdle();

      TextView textView = (TextView) view;
      TextViewCompat.setCompoundDrawablesRelative(textView, start, top, end, bottom);

      uiController.loopMainThreadUntilIdle();
    }
  };
}
 
开发者ID:material-components,项目名称:material-components-android,代码行数:29,代码来源:TestUtilsActions.java

示例10: getView

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
@Override
@NonNull
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
    TextView textView = initTextView(position, convertView, parent);
    if (textView != convertView) {
        TextViewCompat.setCompoundDrawablesRelative(
                textView, createIcon(), null, null, null);
    }
    return textView;
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:11,代码来源:DiscussionPostsSpinnerAdapter.java

示例11: setIcon

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
public void setIcon(Drawable icon) {
	if(icon != null) {
		icon = DrawableCompat.wrap(icon);
		icon = icon.mutate();
		icon.setBounds(0, 0, this.mIconSize, this.mIconSize);
		DrawableCompat.setTintList(icon, this.mIconTintList);
	}

	TextViewCompat.setCompoundDrawablesRelative(this, icon, null, null, null);
}
 
开发者ID:fython,项目名称:BiliNyan-Android,代码行数:11,代码来源:NavigationMenuItemView.java

示例12: getView

import android.support.v4.widget.TextViewCompat; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
    LvMenuItem item = mItems.get(position);
    switch (item.type)
    {
        case LvMenuItem.TYPE_NORMAL:
            if (convertView == null)
            {
                convertView = mInflater.inflate(R.layout.design_drawer_item, parent,
                        false);
            }
            TextView itemView = (TextView) convertView;
            itemView.setText(item.name);
            Drawable icon = mContext.getResources().getDrawable(item.icon);
            setIconColor(icon);
            if (icon != null)
            {
                icon.setBounds(0, 0, mIconSize, mIconSize);
                TextViewCompat.setCompoundDrawablesRelative(itemView, icon, null, null, null);
            }

            break;
        case LvMenuItem.TYPE_NO_ICON:
            if (convertView == null)
            {
                convertView = mInflater.inflate(R.layout.design_drawer_item_subheader,
                        parent, false);
            }
            TextView subHeader = (TextView) convertView;
            subHeader.setText(item.name);
            break;
        case LvMenuItem.TYPE_SEPARATOR:
            if (convertView == null)
            {
                convertView = mInflater.inflate(R.layout.design_drawer_item_separator,
                        parent, false);
            }
            break;
    }

    return convertView;
}
 
开发者ID:hongyangAndroid,项目名称:Android_Blog_Demos,代码行数:44,代码来源:NavListViewActivity.java


注:本文中的android.support.v4.widget.TextViewCompat.setCompoundDrawablesRelative方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。