2014-01-31 70 views
0

我的一个xml文件没有找到样式中定义的属性。 我认为风格是正确的,因为它与其他文件一起工作。 没有一种风格确实有效。它说我需要定义layout_width和layout_height属性,但我是这样做的。无法找到自定义样式

我认为给你一个例子比较简单。如果你需要整个XML文件,这是没有问题的。

<RelativeLayout 
    style="@style/relativeLayout_multiplechoicefrage_aufloesung_content" > 

<style name="relativeLayout_multiplechoicefrage_aufloesung_content"> 
    <item name="android:layout_width">match_parent</item> 
    <item name="android:layout_height">wrap_content</item> 
    <item name="android:orientation">vertical</item> 
    <item name="android:layout_marginLeft">@dimen/frage_content_marginLeft</item> 
    <item name="android:layout_marginRight">@dimen/frage_content_marginRight</item> 
</style> 

我已经清理了项目,但是这并没有奏效。

希望任何人都可以找到解决方案。

在此先感谢!

回答

0

您是否在与您的布局相同的文件中定义了样式(您的示例表明了这一点)?我想你已经把你的风格在res /值这样的文件夹:

RES /价值/ styles.xml

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
<style name="relativeLayout_multiplechoicefrage_aufloesung_content"> 
    <item name="android:layout_width">match_parent</item> 
    <item name="android:layout_height">wrap_content</item> 
    <item name="android:orientation">vertical</item> 
    <item name="android:layout_marginLeft">@dimen/frage_content_marginLeft</item> 
    <item name="android:layout_marginRight">@dimen/frage_content_marginRight</item> 
</style> 
</resources> 

那么你应该能够引用它就像你的代码示例现在就做。

+0

是的,它在这个文件中。 正如我所提到的,相同的样式在其他布局文件中起作用。 –