Sau khi tôi gọi phương thức setCompoundDrawables
, hợp chất drawable không được hiển thị ..setCompoundDrawables Gọi() không hiển thị Compound drawable
Drawable myDrawable = getResources().getDrawable(R.drawable.btn);
btn.setCompoundDrawables(myDrawable, null, null, null);
Bất kỳ suy nghĩ?
Như đã nêu trong câu trả lời bên dưới, biến thể của phương thức có tên '(..) WithIntrinsicBounds' cần được gọi. Trên một lưu ý phụ, 'padding' cho Drawable Compound phải được đặt ** sau ** cuộc gọi này để gây ra hiệu ứng – Dr1Ku
[document] (http://developer.android.com/reference/android/widget/TextView. html # setCompoundDrawables% 28android.graphics.drawable.Drawable,% 20android.graphics.drawable.Drawable,% 20android.graphics.drawable.Drawable,% 20android.graphics.drawable.Drawable% 29) nói: * Bản vẽ phải có ['setBounds (Rect)'] (http://developer.android.com/reference/android/graphics/drawable/Drawable.html#setBounds (android.graphics.Rect)) được gọi. * –
hi hunterp, vừa gặp bạn tại quán cà phê (Angel), bây giờ tôi biết bạn biết Android Drawables là gì (và có lẽ bạn đã đánh cắp bộ nhớ lỗi khi làm việc với nhiều người trong số họ), tôi có thể nói với bạn về một số dự án tôi đã cộng tác đã phải đối phó với vấn đề này, hãy kiểm tra https://github.com/JakeWharton/DiskLruCache (mà tôi đã cộng tác để làm cho android thân thiện hơn) được sử dụng bởi Picasso (https://github.com/square/picasso) – Gubatron