Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.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设置维度获取错误:(100,33)不允许使用字符串类型(位于高度和带值的换行内容)_Android_Android Layout_Compiler Errors - Fatal编程技术网

Android设置维度获取错误:(100,33)不允许使用字符串类型(位于高度和带值的换行内容)

Android设置维度获取错误:(100,33)不允许使用字符串类型(位于高度和带值的换行内容),android,android-layout,compiler-errors,Android,Android Layout,Compiler Errors,我设置了一个资源维度: <?xml version="1.0" encoding="utf-8"?> <resources> <dimen name="font_size">36sp</dimen> <dimen name="layout_height">wrap_content</dimen> <dimen name="layout_width">wrap_content</dim

我设置了一个资源维度:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="font_size">36sp</dimen>
    <dimen name="layout_height">wrap_content</dimen>
    <dimen name="layout_width">wrap_content</dimen>
</resources>
<Button
    android:layout_columnWeight="1"
    android:background="@drawable/button_style"
    android:id="@id/btnAC"
    android:layout_width="@dimen/layout_width"
    android:layout_height="@dimen/layout_height"
    android:text="@string/valAC"
    android:textColor="@color/white"
    android:textSize="@dimen/font_size" />

36便士
包装内容
包装内容
并使用以下内容引用它:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="font_size">36sp</dimen>
    <dimen name="layout_height">wrap_content</dimen>
    <dimen name="layout_width">wrap_content</dimen>
</resources>
<Button
    android:layout_columnWeight="1"
    android:background="@drawable/button_style"
    android:id="@id/btnAC"
    android:layout_width="@dimen/layout_width"
    android:layout_height="@dimen/layout_height"
    android:text="@string/valAC"
    android:textColor="@color/white"
    android:textSize="@dimen/font_size" />

但是我在尝试运行应用程序时遇到以下错误。
错误:(100,33)不允许使用字符串类型(在“布局高度”处,值为“包装内容”)。包装内容不支持作为资源维度。只需在布局文件中使用换行内容,而不是@dimen/layout\u高度和@dimen/layout\u宽度

wrap\u内容不支持作为资源维度。只需在布局文件中使用换行内容,而不是@dimen/layout\u高度和@dimen/layout\u宽度

不能在资源文件中添加换行内容

你应该这样做

<Button
    android:layout_columnWeight="1"
    android:background="@drawable/button_style"
    android:id="@id/btnAC"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/valAC"
    android:textColor="@color/white"
    android:textSize="@dimen/font_size" />

您不能在资源文件中添加包装内容

你应该这样做

<Button
    android:layout_columnWeight="1"
    android:background="@drawable/button_style"
    android:id="@id/btnAC"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/valAC"
    android:textColor="@color/white"
    android:textSize="@dimen/font_size" />


使用-2dp而不是包装内容是否有效?我使用它的主要目的是测试很多按钮。因此,我一直在更改布局高度和布局宽度的值。我不想更改所有按钮中的值,而是想更改一次。我不确定。试试看。根据这个问题,如果在为按钮创建自定义样式时支持wrap_内容,您也可以尝试这样做。这也使得一次对所有按钮进行更改变得更容易。通读链接,找到一个有效的解决方案。谢谢。用-2dp代替wrap_内容行吗?我使用它的主要目的是测试很多按钮。因此,我一直在更改布局高度和布局宽度的值。我不想更改所有按钮中的值,而是想更改一次。我不确定。试试看。根据这个问题,如果在为按钮创建自定义样式时支持wrap_内容,您也可以尝试这样做。这也使得一次对所有按钮进行更改变得更容易。通读链接,找到一个有效的解决方案。谢谢。像这样试试>像这样试试>