自定义搜索栏没有显示

时间:2017-05-24 08:17:32

标签: android xml seekbar

我创建了一个自定义搜索栏。 它在Android模拟器上看起来很正常,但只有拇指在实际设备上可见。 如果从xml文件中的搜索条的属性中减去android:progressDrawable或android:thumb属性,则拇指或进度条看起来很正常。 当您同时应用两个属性时,搜索栏无法正确显示。

这是来源。

activity_main.xml中

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="speakeragent.com.myapplication.MainActivity">

<SeekBar
    android:id="@+id/seekBar1"
    android:layout_width="368dp"
    android:layout_height="wrap_content"
    android:progressDrawable="@drawable/seekbar_seekbar1"
    android:thumb="@drawable/seekbar_thumb1"
    android:thumbOffset="0dp"
    tools:layout_editor_absoluteY="0dp"
    tools:layout_editor_absoluteX="8dp"
    tools:ignore="MissingConstraints" />

</android.support.constraint.ConstraintLayout>

seekbar_seekbar1.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
    <shape android:shape="line">
        <stroke android:width="6dp" android:color="#D5D5D5" />
    </shape>
</item>
<item android:id="@android:id/secondaryProgress">
    <clip>
        <shape android:shape="line">
            <stroke android:width="6dp" android:color="#B2CCFF"/>
        </shape>
    </clip>
</item>

<item android:id="@android:id/progress">
    <clip>
        <shape android:shape="line">
            <stroke android:width="6dp" android:color="#6799FF"/>
        </shape>
    </clip>
</item>
</layer-list>

seekbar_thumb1.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#B2CCFF"></solid>
<stroke android:width="2dp"
    android:color="#B2CCFF"/>
<size
    android:width="6dp"
    android:height="6dp"/>
</shape>

0 个答案:

没有答案
相关问题