首先,给您TextView
一个 ID,以便您可以在以下位置找到它Activity
:
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:drawableTop="@drawable/new" />
其次,在你Activity
找到你的并在调用之后TextView
在你的方法中获取复合可绘制对象:onCreate
setContentView
TextView textView = (TextView) findViewById(R.id.textView);
// Left, top, right, bottom drawables.
Drawable[] compoundDrawables = textView.getCompoundDrawables();
// This is the top drawable.
Drawable topCompoundDrawable = compoundDrawables[1];