I am working from Wallace Jackson's "Android Apps for Absolute Beginners", 3rd, ed.
Currently at the end of Chapter 9 (p. 350).
I have the PNG files in the resource directories, the imagebutton state files, and the main activity layout updated. I'm getting some unexpected behavior which isn't surprising since most of the books code samples don't really work out of the box, but I'm a little puzzled on this one. The image buttons do not display in the left pane of the sliding pane layout. I can see three little white rectanges where the images should be, but they should be squares (well, circles, but technically the images are still squares with transparency). There should be little pictures of galaxies in them, too.
Android studio isn't giving me any errors and the state files even have thumbnails showing the appropriate button state resource.
I'm using AndroidStudio 1.1.0 with JRE 1.7.0_71. I am debugging on a Google Nexus 7 with Android 5.1
Button States File (note that stackoverflow is obfiscating the terminating selector tag)
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_hovered="true" android:drawable="@drawable/imagebutton1hover" />
<item android:state_pressed="true" android:drawable="@drawable/imagebutton1press" />
<item android:state_focused="true" android:drawable="@drawable/imagebutton1focus" />
<item android:drawable="@drawable/imagebutton1normal" />
The layout file
<android.support.v4.widget.SlidingPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/spLayout"
android:background="@drawable/ninepatchframe">
<LinearLayout
android:layout_width="110dp"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:orientation="vertical">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/galaxyOne"
android:src="@drawable/ibstates1"
android:contentDescription="@string/galaxyone"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/galaxyTwo"
android:src="@drawable/ibstates2"
android:contentDescription="@string/galaxytwo"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/galaxyThree"
android:src="@drawable/ibstates3"
android:contentDescription="@string/galaxythree"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="@drawable/galaxyinfoscreen">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#00000000"
android:layout_margin="12dp">
<TextView
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:layout_marginLeft="48dp" android:textStyle="bold"/>
<TextView
android:text="@string/galaxy_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF" />
<TextView
android:text="@string/galaxy_solar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/galaxy_habit"
android:textColor="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/galaxy_colony"
android:textColor="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/galaxy_pop"
android:textColor="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/galaxy_fleet"
android:textColor="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/galaxy_ships"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#00000000"
android:layout_marginTop="33dp">
<TextView
android:text="@string/name_data"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:id="@+id/name"/>
<TextView
android:text="@string/solar_data"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:id="@+id/solar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/habit_data"
android:textColor="#FFFFFF"
android:id="@+id/habit"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/colony_data"
android:textColor="#FFFFFF"
android:id="@+id/colony"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pop_data"
android:textColor="#FFFFFF"
android:id="@+id/pop"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/fleet_data"
android:textColor="#FFFFFF"
android:id="@+id/fleet"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ships_data"
android:textColor="#FFFFFF"
android:id="@+id/ships"/>
</LinearLayout>
</LinearLayout>
Another strange thing... don't think it's related, but who knows. The screen shots in the book show the nine patch panel around the entire sliding pane panel, but in my application the nine patch is completely covered by the right panel (can't see it on that side at all).
Any thoughts?
The answer was already posted by someone else. Unfortunately for him the OP of the linked post never acknowledged the correct answer from PSIXO.
image button with selector in android studio error rendering
For those of you who don't feel like reading the entire thread the physical file name must end in ".xml". The book on Android programming instructs the reader to create a file named "ibstates", but the name must be "ibstates.xml" or Android Studio will break and quit on referencing it as a resource.