2017-06-16 12 views
1

AndroidでProgressBarの「進行状況」の高さを変更することはできますか?この効果を得るには、「背景線」よりも大きいのですか?進捗バーの「進捗線」の高さを変更するにはどうすればよいですか?

what I want to achieve!!!

私は私のカスタムprogressBarDrawableに背景や進捗状況の項目にサイズを設定しようとしたが、動作するようには思えません。ここで

<ProgressBar 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:indeterminate="false" 
      android:max="100" 
      android:progress="50" 
      android:paddingTop="10dp" 
      android:paddingBottom="10dp" 
      android:progressDrawable="@drawable/xml_progress_bar_line" 
      style="@style/Widget.AppCompat.ProgressBar.Horizontal"/> 

xml_progress_bar_line.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> 
      <size 
       android:height="5dp"/> 
      <solid 
       android:color="@color/grey" /> 
     </shape> 
    </item> 

    <item 
     android:id="@android:id/progress"> 
     <clip> 
      <shape> 
       <size 
        android:height="10dp"/> 
       <solid 
        android:color="@color/green" /> 
       <corners 
        android:radius="10dp"/> 
      </shape> 
     </clip> 
    </item> 
</layer-list> 

答えて

1

変更maxHeightminHeight明示的layout_heightを設定し、その後、互いに等しくします。私がプログレスバーを使用していないことになったhttps://xinyustudio.wordpress.com/2014/08/19/android-change-progressbar-height/

enter image description here

+0

素早く詳細な回答Dayanに感謝します。しかし、私が必要とするものではありません。私は実際には進行状況バーを使用していませんでした。 – hakobyanheghine

0

mProgressBar.setScaleY(3f);

は、ここで私から取った例だ -

また、あなたはまた、垂直方向のスケールを設定することができます@android:style/Widget.ProgressBar.Horizontal

を使用してみてくださいすべて!

私はちょうど相対レイアウトで2行を使用しました。ここに対応するコードです!ここで

は、プログレスバーの背景ラインXML( xml_custom_progress_bar_bg.xml)である:ここでは

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

    <corners 
     android:radius="4dp"/> 
    <solid 
     android:color="@color/light_grey"/> 

</shape> 

あるプログレスバー "進捗ライン" XML(xml_custom_progress_bar_progress.xml):

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

    <corners 
     android:radius="4dp"/> 
    <gradient 
     android:angle="270" 
     android:startColor="@color/green" 
     android:endColor="@color/green"/> 

</shape> 

進捗バーのコンテナは次のとおりです。

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="4dp" 
      android:layout_centerVertical="true" 
      android:background="@drawable/xml_custom_progress_bar_bg"/> 

     <View 
      android:layout_width="0dp" 
      android:layout_height="8dp" 
      android:layout_centerVertical="true" 
      android:background="@drawable/xml_custom_progress_bar_progress"/> 

    </RelativeLayout> 

次に、進捗状況を手動で計算し、プログラムによって「進捗線」の幅を設定します。

関連する問題