How can I debug Android style inheritance issue?

When doing web development, you can check the element and see which classes provide the css rules. Is there an equivalent for Android development?

TL; DR; Here is an example of a style inheritance problem that I solved and solved:

I had a Holo theme dialog box, but the text color was dark even when I tried to set the text color to white.

This dialog box:

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"> <ListView android:id="@android:id/list" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/Theme.Dialog"/> </RelativeLayout> 

In the style.xml resource:

 <style name="Theme.Dialog" parent="android:style/Theme.Holo.Dialog"> <item name="android:windowTitleStyle">@android:style/TextAppearance.Large</item> <item name="android:textColor">@color/solid_white</item> <item name="android:windowNoTitle">true</item> </style> 

It turned out that I used Fragment , whose Activity was ListActivity , and it defined getView, which created a view from the xml style, which set the text color to dark. It would be interesting to see what sets the color of the text.

+7
source share
1 answer

I agree with the comments on your question, but for the future, if you want to get an idea of ​​the hierarchy of views (rather than styles) for your application, you can do this in Eclipse.

Launch the app. Window> Open Perspective> DDMS. In the DDMS area, click the icon on the left that looks like a stack of phones (next to the camera icon).

You can navigate the screen and visually display the hierarchy of views.

May help in some way.

0
source

All Articles