Can you give more information about what does not work when running this code? Isn't that capturing what you want? Crash?
Make sure you modify R.id.layoutroot correctly using the root layout ... Also, it looks like this will work ...
<com.example.android.snake.SnakeView android:id="@+id/snake" android:layout_width="match_parent" android:layout_height="match_parent" tileSize="24" /> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/text" android:text="@string/snake_layout_text_text" android:visibility="visible" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:gravity="center_horizontal" android:textColor="#ff8888ff" android:textSize="24sp"/> </RelativeLayout>
Edit ...
So, for example, if you use this layout, which you just put in there, you must change R.id.layout to R.id.snake , which is because of this line: android:id="@+id/snake" .
I donβt think there is an easy way to find / get the identifier of the βrootβ view layout (if you want to take a screenshot of what the phone shows.
I just checked the launchpad and another application, it looks like most applications are placed in FrameLayout with id / content, so you can try using android.R.id.content , but there is no guarantee that this will work every time ...
source share