Android的搜索栏裁剪拇指 [英] Android seekbar clipped thumb

查看:130
本文介绍了Android的搜索栏裁剪拇指的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一些奇怪的problem..I实现了一个搜索栏自定义thumb..and,当我跑了HTC Desire的我的应用程序,这一切工作fine..but,当我跑这对三星Galaxy,拇指变得裁剪!

下面是截图..

愿望:

三星Galaxy:

我将不胜感激任何thoughts..tnx

myprogress.xml:

 <层列表的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>

<项目机器人:ID =@机器人:ID /背景>
    <形状>
        <角落
            机器人:半径=10dp/>
        <梯度
                机器人:startColor =@彩色/灰度
                机器人:centerColor =@彩色/灰度
                机器人:centerY =0.75
                机器人:endColor =@彩色/灰度
                机器人:角=270
        />
    < /形状>
< /项目>

<项目机器人:ID =@机器人:ID / secondaryProgress>
    <夹>
        <形状>
        <角落
            机器人:半径=10dp/>
            <梯度
                    机器人:startColor =@色/白
                    机器人:centerColor =@色/白
                    机器人:centerY =0.75
                    机器人:endColor =@色/白
                    机器人:角=270
            />
        < /形状>
    < /剪辑>
< /项目>

<项目机器人:ID =@机器人:ID /进步>
    <夹>
        <形状>
        <角落
            机器人:半径=10dp/>
            <梯度
                机器人:startColor =#FFA500
                机器人:centerColor =@色/黄
                机器人:centerY =0.75
                机器人:endColor =@色/黄
                机器人:角=270
            />
        < /形状>
    < /剪辑>
< /项目>
 

风格:

 <样式名称=mySeekBar>
    <项目名称=机器人:indeterminateOnly>假< /项目>
    <项目名称=机器人:progressDrawable> @可绘制/ myprogress< /项目>
    <项目名称=机器人:indeterminateDrawable> @android:绘制/ progress_horizo​​ntal< /项目>
    <项目名称=安卓了minHeight> 10dip< /项目>
    <项目名称=安卓了maxHeight> 10dip< /项目>
    <项目名称=机器人:拇指> @可绘制/拇指< /项目>
    <项目名称=机器人:thumbOffset> 4DP< /项目>
    <项目名称=机器人:可聚焦>真< /项目>
 

搜索栏的xml:

 <搜索栏机器人:ID =@ + ID / player_seek_horizo​​ntal
        机器人:layout_gravity =center_vertical
        机器人:最大=100
        机器人:layout_marginLeft =50dp
        机器人:layout_width =180dp
        机器人:拇指=@可绘制/拇指
        机器人:layout_height =WRAP_CONTENT
        风格=@风格/ mySeekBar
        机器人:背景=@可绘制/ background_transparent_rounded
        机器人:paddingRight =4DP机器人:以下属性来=4DP/>
 

解决方案

调整安卓以下属性来安卓paddingRight 机器人:thumbOffset 属性的搜索栏来达到预期的效果。

填充左右应该是大拇指的宽度的一半。

I ran into some weird problem..I implemented a seekbar with custom thumb..and when I ran my app on HTC Desire, it all works fine..but, when I ran it on Samsung Galaxy, the thumb becomes clipped!

Here are the screenshots..

Desire:

Samsung Galaxy:

I would be grateful for any thoughts..tnx

myprogress.xml:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item android:id="@android:id/background">
    <shape>
        <corners
            android:radius="10dp" />
        <gradient
                android:startColor="@color/gray"
                android:centerColor="@color/gray"
                android:centerY="0.75"
                android:endColor="@color/gray"
                android:angle="270"
        />
    </shape>
</item>

<item android:id="@android:id/secondaryProgress">
    <clip>
        <shape>
        <corners
            android:radius="10dp" />
            <gradient
                    android:startColor="@color/white"
                    android:centerColor="@color/white"
                    android:centerY="0.75"
                    android:endColor="@color/white"
                    android:angle="270"
            />
        </shape>
    </clip>
</item>

<item android:id="@android:id/progress">
    <clip>
        <shape>
        <corners
            android:radius="10dp" />
            <gradient
                android:startColor="#FFA500"
                android:centerColor="@color/yellow"
                android:centerY="0.75"
                android:endColor="@color/yellow"
                android:angle="270"
            />
        </shape>
    </clip>
</item>

style:

<style name="mySeekBar">
    <item name="android:indeterminateOnly">false</item>
    <item name="android:progressDrawable">@drawable/myprogress</item>
    <item name="android:indeterminateDrawable">@android:drawable/progress_horizontal</item>
    <item name="android:minHeight">10dip</item>
    <item name="android:maxHeight">10dip</item>
    <item name="android:thumb">@drawable/thumb</item>
    <item name="android:thumbOffset">4dp</item>
    <item name="android:focusable">true</item>

seekbar xml:

<SeekBar android:id="@+id/player_seek_horizontal"
        android:layout_gravity="center_vertical" 
        android:max="100" 
        android:layout_marginLeft="50dp" 
        android:layout_width="180dp" 
        android:thumb="@drawable/thumb" 
        android:layout_height="wrap_content" 
        style="@style/mySeekBar" 
        android:background="@drawable/background_transparent_rounded" 
        android:paddingRight="4dp" android:paddingLeft="4dp"/>

解决方案

Adjust the android:paddingLeft, android:paddingRight and android:thumbOffset properties of your SeekBar to achieve desired results.

Padding right and left should be half of thumb's width.

这篇关于Android的搜索栏裁剪拇指的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆