Reputation: 43
I'm try to set right-drawable to a TextView (in header of list view). I'm setting up the bounds but it's not helping. setDrawablesWithInstrinctBounds() works fine.
Here is code:
private View getHeaderView() {
final LayoutInflater inflater = getActivity().getLayoutInflater();
final View view = inflater.inflate(R.layout.legislation_article_list_header, null, false);
final TextView textView = (TextView) view.findViewById(R.id.sEdition);
headerSpinner = textView;
final Drawable d = getActivity().getResources().getDrawable(R.drawable.spinner_arrow_down);
d.setBounds(new Rect(0, 0, headerSpinner.getHeight(), headerSpinner.getHeight()));
headerSpinner.setCompoundDrawables(null, null, d, null);
textView.setOnClickListener(new View.OnClickListener() {
.............
}
});
return view;
}
What is the problem?
Upvotes: 3
Views: 8040
Reputation: 5368
Try this:
Drawable d = getActivity().getResources().getDrawable(R.drawable.spinner_arrow_down);
d.setBounds(new Rect(0, 0, headerSpinner.getHeight(), headerSpinner.getHeight()));
textView.setCompoundDrawablesWithIntrinsicBounds( d , null, null, null);
or
textView.setCompoundDrawablesWithIntrinsicBounds( R.drawable.smiley, 0, 0, 0);
Upvotes: 12