3

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

“match_parent”(自定义ListView中的父项是item(row))值无效并将高度设置为minHeigh,只有显式值可以设置高度(示例:“100dip”),我也尝试将值设置为我的getView()方法:

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

它没有帮助,有什么问题?请帮忙 )

4

0 回答 0