我看到一個我從未見過的錯誤,因爲它阻止了我的一些佈局文件在Eclipse中呈現。它們在運行時渲染良好。Android佈局錯誤:「資源ID <res_id>不是STYLE類型(而不是attr)」
,在圖形佈局編輯器(和我的錯誤日誌)顯示出來的錯誤: 「種源ID 0x1010081不是類型樣式(代替attr)使用」
我在搜索資源ID 0x1010081我的R文件,我無法找到它,所以我猜可能不知何故,我與內置的Android attr有衝突。我還驗證了我的所有樣式屬性都指向了實際樣式,而不是attr。任何幫助讚賞。
這裏是我的完整佈局代碼:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bkg_light"
android:padding="@dimen/padding_med" >
<RelativeLayout
android:id="@+id/relativeLayout_activity"
android:layout_width="fill_parent"
android:layout_height="@dimen/button_height"
android:background="@drawable/xml_button"
android:padding="@dimen/padding_med" >
<TextView
style="@style/text_large_bold_white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="@string/activity" />
<TextView
android:id="@+id/textView_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/margin_med"
android:layout_toLeftOf="@+id/textView_arrow_right_start_date"
android:text="@string/none_selected"/>
<TextView
android:id="@+id/textView_arrow_right_start_date"
style="@style/arrow_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout>
<!-- kv Duration -->
<RelativeLayout
android:id="@+id/relativeLayout_duration"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/relativeLayout_activity"
android:layout_marginTop="@dimen/margin_large"
android:background="@drawable/xml_button">
<TextView
android:id="@+id/textView_duration"
style="@style/text_large_bold_white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="@string/duration_lc"
android:paddingLeft="@dimen/padding_med"/>
<Spinner
android:id="@+id/spinner_duration"
android:layout_width="wrap_content"
android:layout_height="@dimen/button_height"
android:layout_alignParentRight="true"
android:entries="@array/array_durations"
android:prompt="@string/duration_lc"
android:spinnerMode="dropdown"
android:clickable="false"/>
</RelativeLayout>
</RelativeLayout>
這是我的styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="arrow_right">
<item name="android:textStyle">bold</item>
<item name="android:textSize">@dimen/text_xxlarge</item>
<item name="android:text">@string/arrow_right</item>
</style>
<style name="button_blue">
<item name="android:textStyle">bold</item>
<item name="android:textColor">@color/white</item>
<item name="android:background">@drawable/selector_button_blue</item>
<item name="android:padding">@dimen/padding_med</item>
</style>
<style name="button_blue_small">
<item name="android:textStyle">bold</item>
<item name="android:textColor">@color/white</item>
<item name="android:background">@drawable/selector_button_blue_small</item>
<item name="android:padding">@dimen/padding_med</item>
</style>
<style name="button_dark">
<item name="android:textStyle">bold</item>
<item name="android:textColor">@color/white</item>
<item name="android:background">@drawable/selector_button_dark</item>
<item name="android:padding">@dimen/padding_med</item>
</style>
<style name="button_light">
<item name="android:textStyle">bold</item>
<item name="android:textColor">@color/black</item>
<item name="android:background">@drawable/selector_button_light</item>
<item name="android:padding">@dimen/padding_med</item>
</style>
<style name="button_light_small">
<item name="android:textStyle">bold</item>
<item name="android:textColor">@color/black</item>
<item name="android:textSize">@dimen/text_small</item>
<item name="android:background">@drawable/selector_button_light</item>
<item name="android:padding">@dimen/padding_small</item>
</style>
<style name="text_small_gray_light">
<item name="android:textSize">@dimen/text_small</item>
<item name="android:textColor">@color/gray_light</item>
</style>
<style name="text_med_bold_gray_light">
<item name="android:textStyle">bold</item>
<item name="android:textSize">@dimen/text_med</item>
<item name="android:textColor">@color/gray_light</item>
</style>
<style name="text_large_bold_white">
<item name="android:textStyle">bold</item>
<item name="android:textSize">@dimen/text_large</item>
</style>
<style name="text_large_bold_black">
<item name="android:textStyle">bold</item>
<item name="android:textSize">@dimen/text_large</item>
<item name="android:textColor">@color/black</item>
</style>
<style name="text_large_bold_gray_dark">
<item name="android:textStyle">bold</item>
<item name="android:textSize">@dimen/text_large</item>
<item name="android:textColor">@color/gray_dark</item>
</style>
<style name="text_large_bold_gray_light">
<item name="android:textStyle">bold</item>
<item name="android:textSize">@dimen/text_large</item>
<item name="android:textColor">@color/gray_light</item>
</style>
<style name="text_large_bold_white">
<item name="android:textStyle">bold</item>
<item name="android:textSize">@dimen/text_large</item>
<item name="android:textColor">@color/white</item>
</style>
<style name="text_large_white">
<item name="android:textSize">@dimen/text_large</item>
<item name="android:textColor">@color/white</item>
</style>
</resources>
這是我的自定義theme.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.P90X" parent="@style/Theme.Sherlock">
<item name="android:textColor">#ffffffff</item>
</style>
</resources>
你能附上完整的錯誤日誌和你的styles.xml? –
@JustinJasmann:列出styles.xml。唯一我得到的是上面列出的那個。 –
你爲什麼不接受正確的答案? – John