2

I am familiar with @drawable but in a repo I cloned I found @r$drawable being used while referring to drawables in items.

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_selected="true" android:drawable="@r$drawable/ic_home_live_pressed" />
</selector>

vs

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_selected="true" android:drawable="@drawable/ic_home_live_pressed"/>
</selector>
ishandutta2007
  • 16,676
  • 16
  • 93
  • 129

1 Answers1

0

the "$" (dollar sign) is used to reference an inner class from Android XML files.

For example:

class Outer {
  class Innter {
  }
}

would referred to as

Outer$Inner 

Normally this is the way to refer to an non-static inner class. The "." (dot) notation is used for static inner classes.

It is weird that the source code you saw is referring to drawable as an non-static inner class because Drawable is an static inner class.

If you could share the link to the repository where you saw such code it would make it easier to explain the reasons why.

Find some more info on this at:

Android XML referencing via dollar sign vs dot sign

Error referencing an inner class View in layout/main.xml

This specific asnwer for the question above has good and up-to-date information on this: https://stackoverflow.com/a/46223464/550967

DallaRosa
  • 5,737
  • 2
  • 35
  • 53