หลังจากที่ฉันเรียกsetCompoundDrawablesเมธอดแล้ว Drawable ผสมจะไม่ปรากฏขึ้น ..
Drawable myDrawable = getResources().getDrawable(R.drawable.btn);
btn.setCompoundDrawables(myDrawable, null, null, null);
ความคิดใด ๆ
setBounds(Rect)เรียกว่า 
                หลังจากที่ฉันเรียกsetCompoundDrawablesเมธอดแล้ว Drawable ผสมจะไม่ปรากฏขึ้น ..
Drawable myDrawable = getResources().getDrawable(R.drawable.btn);
btn.setCompoundDrawables(myDrawable, null, null, null);
ความคิดใด ๆ
setBounds(Rect)เรียกว่า 
                คำตอบ:
setCompoundDrawablesWithIntrinsicBoundsฉันจำเป็นต้องใช้
ใช้สิ่งนี้ (ฉันทดสอบ) มันใช้งานได้ดี
Drawable image = context.getResources().getDrawable( R.drawable.ic_action );
int h = image.getIntrinsicHeight(); 
int w = image.getIntrinsicWidth();   
image.setBounds( 0, 0, w, h );
button.setCompoundDrawables( image, null, null, null );
              EditText#setCompoundDrawablesWithIntrinsicBoundsต้องใช้อย่างน้อย API 17
                    ภาพว่างเปล่าเนื่องจากไม่ได้ระบุขอบเขต คุณอาจใช้setCompoundDrawables()แต่ก่อนที่คุณควรระบุขอบเขตของรูปภาพโดยใช้Drawable.setBounds()วิธีการ
ตัวอย่างตั้งไว้ที่ด้านบน:
view.setCompoundDrawablesWithIntrinsicBounds(
    null,
    getResources().getDrawable(R.drawable.some_img),
    null,
    null
);
ลำดับอาร์กิวเมนต์: (ซ้าย, บน, ขวา, ล่าง)
ง่ายขึ้นอีกเล็กน้อย:
Drawable image = context.getResources().getDrawable(R.drawable.ic_action );
image.setBounds( 0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight() );
button.setCompoundDrawables( image, null, null, null );
              มันเลิกใช้แล้วใน API 22
รหัสนี้มีประโยชน์สำหรับฉัน:
Drawable drawable = ResourcesCompat.getDrawable(getResources(),R.drawable.wen, null);
drawable.setBounds(0, 0, drawable.getMinimumWidth(),
drawable.getMinimumHeight());
tv.setCompoundDrawables(drawable, null, null, null);
              ใน Kotlin:
1) ชุดdrawable:
val drawable = ContextCompat.getDrawable(context!!,R.drawable.ic_image)?.apply {
    setBounds(0, 0, intrinsicWidth, intrinsicHeight)
}
หรือ
val drawable = ResourcesCompat.getDrawable(resources, R.drawable.ic_image, null)?.apply {
    setBounds(0, 0, minimumWidth, minimumHeight)
}
2) ชุดTextView:
textView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null)
หรือ
button.setCompoundDrawables(null, drawable, null, null)
              setCompoundDrawablesWithIntrinsicBoundsจะใช้ได้ ..
                    ตัวอย่างกับ Kotlin:
    val myView = layoutInflater.inflate(R.layout.my_view, null) as TextView
    myView.setCompoundDrawablesWithIntrinsicBounds(0, myDrawable, 0, 0)
              รูปภาพจะไม่ปรากฏเนื่องจากคุณไม่ได้ระบุขอบเขตดังนั้นคุณจึงมี 2 ตัวเลือกที่นี่
วิธีที่ 1
ใช้setCompoundDrawablesWithIntrinsicBoundsวิธีการที่แสดงด้านล่าง
Drawable myDrawable = getResources().getDrawable(R.drawable.btn);
btn. setCompoundDrawablesWithIntrinsicBounds(myDrawable, null, null, null);
วิธีที่ 2
คุณสามารถใช้ขอบเขตกับ drawable ก่อนนำไปใช้กับ TextView ดังที่แสดงด้านล่าง
Drawable myDrawable = getResources().getDrawable(R.drawable.btn);
myDrawable.setBounds( 0, 0, myDrawable.getIntrinsicWidth(), myDrawable.getIntrinsicHeight());
btn.setCompoundDrawables(myDrawable, null, null, null);
แค่นั้นแหละ.
(..)WithIntrinsicBoundsจะต้องมีการเรียก ในหมายเหตุด้านpaddingสำหรับการจับสลาก Compound ต้องตั้งค่าหลังจากการโทรนี้เพื่อให้เกิดผลกระทบ