Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.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 9修补程序内容区域错误_Android_Nine Patch - Fatal编程技术网

Android 9修补程序内容区域错误

Android 9修补程序内容区域错误,android,nine-patch,Android,Nine Patch,似乎我的内容区域与9patch文件所说的内容区域不匹配 这是我的补丁文件。 这是一张图片,上面有一个项目,但是文本被过早地删除了,应该是“Varenr”。我不明白为什么有这么大的空白而不是文本?? 这是微调器的xml布局: <Spinner android:id="@+id/sortSpinner" android:layout_width="0dp" android:layout_weight="

似乎我的内容区域与9patch文件所说的内容区域不匹配
这是我的补丁文件。


这是一张图片,上面有一个项目,但是文本被过早地删除了,应该是“Varenr”。我不明白为什么有这么大的空白而不是文本??

这是微调器的xml布局:

        <Spinner
            android:id="@+id/sortSpinner"
            android:layout_width="0dp"
            android:layout_weight="4"
            android:layout_height="35dp"
            android:layout_marginBottom="10dp"
            android:layout_marginTop="10dp"
            android:background="@drawable/spinner_background"
            android:drawSelectorOnTop="true"
            android:focusable="false"
            android:focusableInTouchMode="false"
            android:prompt="@string/sort" />

以及微调器项的

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    style="?android:attr/spinnerItemStyle"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:ellipsize="none"
    android:gravity="center"
    android:singleLine="true" />

提前谢谢你的帮助

作为结束语,问题中的9patch:

编辑: 微调器所在的整条生产线:

    <LinearLayout
        android:id="@+id/headerLabel"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:background="@color/transparent"
        android:orientation="horizontal"
        android:weightSum="11">

        <LinearLayout
            android:layout_width="0dp"
            android:layout_weight="3"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:id="@+id/sortAmountLabel"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dip"
                android:singleLine="false"
                android:textColor="@color/solid_red"
                android:textSize="15dp" />

            <TextView
                android:id="@+id/sortLabel"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5dip"
                android:text="Produkter"
                android:singleLine="true"
                android:textColor="@color/solid_red"
                android:textSize="15dp" />

        </LinearLayout>

        <Button
            android:id="@+id/filterBtn"
            android:layout_width="0dp"
            android:layout_height="35dp"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="15dp"
            android:layout_marginTop="10dp"
            android:layout_weight="4"
            android:background="@drawable/button_background_red"
            android:clickable="true"
            android:singleLine="true"
            android:onClick="setFilterList"
            android:text="Filtrér"
            android:textColor="@color/solid_white"
            android:textSize="15dp"
            android:textStyle="bold" />


        <Spinner
            android:id="@+id/sortSpinner"
            android:layout_width="0dp"
            android:layout_weight="4"
            android:layout_height="35dp"
            android:paddingRight="30dp"
            android:layout_marginBottom="10dp"
            android:layout_marginTop="10dp"
            android:background="@drawable/spinner_background"
            android:drawSelectorOnTop="true"
            android:focusable="false"
            android:focusableInTouchMode="false"
            android:prompt="@string/sort" />
    </LinearLayout>

现在,我就是这样重新制作的:

结果如下:

确保扩展名为.9.png

[编辑]

这是应用于TextView时的结果:

屏幕是一个旧的ldpi设备(240x320@120 dpi)

我就是这样应用它的:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/stripes_vert_4"
    >

    <!-- ... -->

    <TextView
        android:id="@+id/txtTitle3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:layout_alignParentBottom="true"
        android:textColor="@android:color/black"
        android:textSize="16sp"
        android:textStyle="bold"
        android:text="Lorem ipsum dolor sit amet"
        android:background="@drawable/spinner_drawable"
    />
</RelativeLayout>
[EDIT3]

在最后的评论中,OP要求(75%的空白+剩余的微调器宽度)如下:

你确定吗

运行屏幕为低分辨率(ldpi)。
但在它旁边的图形编辑器中,您可以看到另一个设备(HTC Desire Bravo)屏幕,它是hdpi

它显示了相同的“问题”:
1/4屏幕宽度

因此,9PNG背景的可拉伸部分(包含文本)被挤出,只有不可拉伸部分(箭头)保持不变

[EDIT4]

在使用9补丁大小后,我可以使部分文本变得可见:

所以,似乎你必须尝试更小的尺寸,直到你得到一个可接受的结果

[EDIT5]

我忘记添加新的spinner 9修补程序(已调整大小)。
这是:


重新缩放时,请注意外边框:它必须完全透明,标记必须全黑

检查:不适用于我的图像,因为我需要它在两个位置(在“>”上方和下方)拉伸。在9-patch中,顶部和左侧是指示拉伸的区域(一个像素足够),底部和右侧是指示内容区域。@Hareshchelana我知道,但它显然不像您上面看到的那样工作……但是文本被过早地删除了,它应该是“Varenr”。我不明白为什么有这么大的空白而不是文本??您能让它按预期工作吗?因为我做不到,所以我试过在两边上下各1个像素。没有区别。在V和文本之间仍然有一个巨大的空间,即使不应该有,我将尝试使用文本视图。给我几分钟。是的,它似乎在工作。。。请查看我的更新答案并将其更改为旋转器?:)完成。现在它使用旋转器。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/stripes_vert_4"
    >

    <!-- ... -->

    <Spinner
        android:id="@+id/spnElements"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:entries="@array/prefs_search_modes"
        android:layout_alignParentBottom="true"
        android:textColor="@android:color/black"
        android:textSize="16sp"
        android:textStyle="bold"
        android:background="@drawable/spinner_drawable"
    />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- Settings -->
    <!-- Word search mode -->
    <string-array name="prefs_search_modes">
        <item>*b* (Contains "b")</item>
        <item>Ab* (Starts with "Ab")</item>
        <item>*bc (Ends in "bc")</item>
        <item>Abc (Exact match)</item>
    </string-array>
</resources>