I would like to know more about such a thing as CompoundDrawable , or rather about the string

 textView.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom); 

What gives the last four parameters (left, top, right, bottom) ?

1 answer 1

Code

  textView.setCompoundDrawablesWithIntrinsicBounds(0,0,0,0) 

allows you to set icons in a textView . left, top, right, bottom position of the icon relative to the text

xml is written like this

 <TextView ... android: drawableTop = "@drawable/ic_launcher" ... /> 
  • t, e can be placed and imageview in the text? And what does the button parameter do? - Vyacheslav
  • not. you can place only resources (R.drawable.ic_lounch), but not ImageView =) - Chaynik
  • ok, I have a picture in the mipmap folder and I want to place it under the text in Relativelayout, If the parameters left, top, right allow you to specify the location of the picture on the screen, then what makes the bottom parameter and what to write to the fourth place? - Vyacheslav
  • bottom - under the text. if you want to set only the bottom, then specify only the bottom, otherwise zeros textView.setCompoundDrawablesWithIntrinsicBounds (0,0,0, R.drawable.ic_launch), If the picture is large, it’s better to use ImageView, Chaynik
  • 2
    (10, 10, 25, 30) - You must specify resource IDs , not magic numbers - Chaynik