自定义(垂直)进度条 - 与父级不匹配

时间:2013-01-02 22:43:50

标签: android progress-bar custom-controls

我有垂直进度条,这里是在drawable文件夹中定义的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>

            <gradient
                    android:startColor="#ff9d9e9d"
                    android:centerColor="#ff5a5d5a"
                    android:centerY ="0.75"
                    android:endColor="#ff747674"
                    android:angle="180"
            />
        </shape>
    </item>     
    <item android:id="@android:id/secondaryProgress">
        <clip android:clipOrientation="vertical" android:gravity="bottom">
            <shape>

                <gradient
                        android:startColor="#80ffd300"
                        android:centerColor="#80ffb600"
                        android:centerY="0.75"
                        android:endColor="#a0ffcb00"
                        android:angle="180"
                />
            </shape>
        </clip>
    </item>     
    <item android:id="@android:id/progress">
        <clip android:clipOrientation="vertical" android:gravity="bottom">
            <shape>

                <gradient
                        android:startColor="#ffffd300"
                        android:centerColor="#ffffb600"
                        android:centerY="0.75"
                        android:endColor="#ffffcb00"
                        android:angle="180"
                />
            </shape>
        </clip>
    </item>

</layer-list>

我已添加到styles.xml:

<style name="Widget"></style>

    <style name="Widget.ProgressBar">
        <item name="android:indeterminateOnly">true</item>
        <item name="android:indeterminateBehavior">repeat</item>
        <item name="android:indeterminateDuration">3500</item>
        <item name="android:minWidth">48dip</item>
        <item name="android:maxWidth">48dip</item>
        <item name="android:minHeight">48dip</item>
        <item name="android:maxHeight">480dip</item>
    </style>

    <style name="Widget.ProgressBar.Vertical">
        <item name="android:indeterminateOnly">false</item>
        <item name="android:progressDrawable">@drawable/vertical_progress_bar</item>
        <item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item>
        <item name="android:minWidth">1dip</item>
        <item name="android:maxWidth">12dip</item>
    </style>

当我使用它时:

<ProgressBar
        android:id="@+id/vertical_progressbar"
        style="@style/Widget.ProgressBar.Vertical"        
        android:layout_width="12dip"
        android:layout_height="match_parent"              
        android:layout_marginRight="5dp" 

&#34; match_parent&#34;(父级是自定义ListView中的项目(行))值无效并将高度设置为minHeigh,只有显式值可以设置高度(例如:&#34; 100dip&# 34), 我也尝试在getView()方法中设置值:

itemRow.vProgressBar.setMinimumHeight(convertView.getHeight()); 

它没有帮助,有什么不对?请帮忙)

0 个答案:

没有答案