简体   繁体   English

我可以创建没有可绘制资源的自定义搜索栏吗

[英]Can I create a custom Seekbar without a drawable resource

I have created a custom SeekBar which uses a LayerList. 我创建了一个使用LayerList的自定义SeekBar。 I haven't used a drawable resource. 我没有使用可绘制资源。

It says here that my "item"... 它说这里是我的“项目” ...

Drawable resource. 可绘制资源。 Required . 必填项 Reference to a drawable resource. 引用可绘制资源。

Will I encounter any problems if I do not create a drawable resource for this item? 如果不为此项目创建可绘制资源,是否会遇到任何问题?

custom_seek_bar.xml: custom_seek_bar.xml:

<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:id="@android:id/bkg">
        <shape>
            <corners android:radius="12dp" />
            <solid
                android:color="@color/white" />
        </shape>
    </item>
    <item android:id="@android:id/prog">
        <clip>
            <shape>
                <corners android:radius="12dp" />
            <solid
                android:color="@color/blue" />
            </shape>
        </clip>
    </item>

</layer-list>

As the docs says: 正如文档所说:

A LayerDrawable is a drawable object that manages an array of other drawables. LayerDrawable是可绘制对象,它管理其他可绘制对象的数组。

The equivalent of in Java code is the Layer Drawable. Java代码中的等效项是Layer Drawable。 ( http://developer.android.com/reference/android/graphics/drawable/LayerDrawable.html ) http://developer.android.com/reference/android/graphics/drawable/LayerDrawable.html

So it will probably not accept it without the resources. 因此,如果没有资源,它可能不会接受它。 It was really a bad idea to give such a generic name (layer-list) to something related only to drawables. 将这样的通用名称(图层列表)赋予仅与可绘制对象相关的名称,确实是一个坏主意。

Hope that it helps! 希望对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM