Android: Where to find the RadioButton Drawable?

微笑、不失礼 提交于 2019-12-01 17:23:10

look under SDK folder /platforms/android-2.0/data/res/ you can access them by either android.R.drawable ( if public ) or need to copy them as drawable to your project

Peterdk

For sake of completeness:

Here some code pieces that show how you I got it working with above accepted answer.

 //Image Setup (Once when creating this view)
 ImageView indicator = (ImageView) findViewById(R.id.RadioStatusImage);
 indicator.setImageDrawable(getResources().getDrawable(android.R.drawable.btn_radio));

 //State Change (In some other method)
  android.R.attr.state_checked
  if (isChecked)
  {
     indicator.setImageState(android.R.attr.state_checked, false);
  }
  else
  {
     indicator.setImageState(View.ENABLED_STATE_SET, false);
  }
  invalidate();

To use the new default animated radio button drawable, the correct answer is in the comment of @sidon:

?android:attr/listChoiceIndicatorSingle

Using this in the custom position relative to text:

<RadioButton
    ...
    android:gravity="center_horizontal|bottom"
    android:drawableTop="?android:attr/listChoiceIndicatorSingle"
    android:button="@null"
    />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!