android.support.v4.widget.TextViewCompat#setCompoundDrawablesRelativeWithIntrinsicBounds ( )源码实例Demo

下面列出了android.support.v4.widget.TextViewCompat#setCompoundDrawablesRelativeWithIntrinsicBounds ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private void addLinkItemView(ViewGroup parent, int resIdText, int resIdDrawable, final String url, String formatArg) {
    TextView view = (TextView) LayoutInflater.from(parent.getContext()).inflate(R.layout.app_details2_link_item, parent, false);
    if (formatArg == null) {
        view.setText(resIdText);
    } else {
        String text = parent.getContext().getString(resIdText, formatArg);
        view.setText(text);
    }
    TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(view, resIdDrawable, 0, 0, 0);
    parent.addView(view);
    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onLinkClicked(url);
        }
    });
}
 
源代码2 项目: materialandroid   文件: PasswordEditText.java
private void setDrawables() {
  Drawable[] drawables = getDrawables();
  if (passwordVisible) {
    drawables[2] = shownIcon;
  } else {
    drawables[2] = hiddenIcon;
  }
  TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(this,
      drawables[0], drawables[1], tintDrawable(drawables[2]), drawables[3]);
}
 
NoVersionsViewHolder(View view) {
    super(view);
    headerView = (TextView) view.findViewById(R.id.information);
    TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(headerView, R.drawable.ic_access_time_24dp_grey600, 0, 0, 0);

    itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            explainIncompatibleVersions();
        }
    });
}
 
/**
 * Depending on whether we are expanded or not, update the icon which indicates whether the
 * user can expand/collapse this item.
 */
protected void updateExpandableItem(boolean isExpanded) {
    TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(headerView, getIcon(), 0, isExpanded ? R.drawable.ic_expand_less_grey600 : R.drawable.ic_expand_more_grey600, 0);
}