我正在尝试向TextView(位于列表视图的标题中)设置正确的Drawable。我已经设置好边界,但似乎没有起作用。使用setDrawablesWithInstrinctBounds()方法则可以正常工作。
以下是代码:
什么是问题?
以下是代码:
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;
}
什么是问题?
setCompoundDrawablesWithIntrinsicBounds(null, null, d, null);
。 - Phantômaxxandroid:drawablePadding="8dp"
,或者在Java中使用setCompoundDrawablePadding(12)
。 - Phantômaxx