Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 找不到自定义样式_Android_Xml - Fatal编程技术网

Android 找不到自定义样式

Android 找不到自定义样式,android,xml,Android,Xml,我的一个xml文件找不到样式中定义的属性。 我认为该样式是正确的,因为它适用于其他文件。 没有一种风格能奏效。它说我需要定义布局宽度和布局高度属性,但我在样式中这样做了 我认为只举一个例子比较简单。如果您需要整个xml文件,这是没有问题的 <RelativeLayout style="@style/relativeLayout_multiplechoicefrage_aufloesung_content" > <style name="relativeLayout_m

我的一个xml文件找不到样式中定义的属性。 我认为该样式是正确的,因为它适用于其他文件。 没有一种风格能奏效。它说我需要定义布局宽度和布局高度属性,但我在样式中这样做了

我认为只举一个例子比较简单。如果您需要整个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>

匹配父项
包装内容
垂直的
@尺寸/碎片含量/边缘左侧
@尺寸/碎片含量/边缘正确
我已经清理了这个项目,但这不起作用

希望任何人都能找到解决办法


提前谢谢

您是否在与布局相同的文件中定义了样式(您的示例表明)?我认为你必须将你的风格放在res/values文件夹中,如下所示:

res/values/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>

匹配父项
包装内容
垂直的
@尺寸/碎片含量/边缘左侧
@尺寸/碎片含量/边缘正确

然后您应该能够像您的代码示例现在所做的那样引用它。

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