2017-10-04 115 views
0

「無法解析symbol'android:layout_width'」

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <item name="colorPrimary">@color/primary_color</item> 
    <item name="colorPrimaryDark">@color/primary_dark_color</item> 
</style> 

<!-- Style for a category of vocabulary words --> 
<style name="CategoryStyle"> 
    <item name="android:layout_width">match_parent</item> 
    <item name="android:layout_height">@dimens/list_item_height</item> 
    <item name="android:gravity">center_vertical</item> 
    <item name="android:padding">16dp</item> 
    <item name="android:textColor">@android:color/white</item> 
    <item name="android:textStyle">bold</item> 
    <item name="android:textAppearance">?android:textAppearanceMedium</item> 
</style> 

上面一個是styles.xml文件。 並從第6行到第12行顯示「Cannot resolve symbol'android:layout_width'」 ..............我想知道問題是什麼?

+0

嘗試更改'layout_width'給它一個角錢如果錯誤去那麼它可能是'match_parent'不允許那裏,因爲父母不知道 – Xenolion

+0

沒有..問題依然存在..... ....它與manifest.xml有什麼關係?我是一個新手在Android ...所以我的問題可能聽起來很愚蠢...... –

+0

不用擔心。但是如果你打算只在一個視圖中使用它,那麼在styles.xml中不需要定義你的完整樣式!轉到該視圖並直接更改! – Xenolion

回答

0

通常這樣的錯誤意味着它的語法問題,但是你的代碼看起來很好。你有這個代碼嵌套在資源標籤內嗎?因爲如果你不這樣做,那可能是問題所在。

+0

是的,我嵌套的資源標籤.... bt仍然有問題 –

+0

我把代碼放在我的styles.xml中,沒有錯誤。看看誰在呼叫「CategoryStyle」,問題一定在那裏。 –