2014-11-20 3 views
2

안녕하세요 저는 사용자 정의보기 및 lifebarprocess.xml을 만들었습니다. 나는 내가 선택한 다른 모든 것들과 함께 나의 커스텀 뷰에 라이프 바를 그리기를 원한다. 그러나 나는 어떻게해야할지 모르겠다 :사용자 정의보기 내에서 진행 막대를 사용합니까?

- 내 뷰 내의 프로세스 바를 참조하고 그 그림을 그릴 수있는 방법을 참조하십시오. - 진도 막대 xml을 바꿀 수 있습니까?

사용자 정의보기 (단락) :

public class Gamecontroller_View extends View implements OnGestureListener{ 

private Paint mPaint; 

public Gamecontroller_View(){ 
     mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 
     mPaint.setColor(Color.BLUE); 
     mPaint.setMaskFilter(new BlurMaskFilter(15, Blur.OUTER)); 
     mPaint.setStyle(Paint.Style.FILL_AND_STROKE); 
} 

    @Override 
     protected void onDraw(Canvas canvas) { 
     super.onDraw(canvas); 

     if (fingerpointer != null){ 
      mPaint.setColor(colors[0]); 
      canvas.drawCircle(fingerpointer.x, fingerpointer.y, 30, mPaint); 
      } 

     //I want to draw a Progressbar's current appearance here 

     } 

} 

lifeprocessbar.xml :

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 
    <item android:id="@android:id/background"> 
    <shape> 
     <corners android:radius="5dip" /> 
     <gradient 
     android:angle="270" 
     android:centerColor="#ff5a5d5a" 
     android:centerY="0.5" 
     android:endColor="#ff747674" 
     android:startColor="#ff9d9e9d" /> 
    </shape> 
    </item> 
    <item android:id="@android:id/progress"> 
    <clip> 
     <shape> 
     <corners android:radius="5dip" /> 
      <gradient 
      android:angle="0" 
      android:endColor="#ff0000" 
      android:startColor="#ff3300" /> 
     </shape> 
    </clip> 
    </item> 
</layer-list> 

lifebarprocess_layout도있다 :

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 


     <ProgressBar 
     android:id="@+id/playerlifeprocessbar" 
     style="?android:attr/progressBarStyleHorizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_marginTop="30dp" 
     android:progress="90" 
     android:progressDrawable="@drawable/lifeprocessbar" /> 


</LinearLayout> 

내 누군가가 도움을 줄 수는 - adavance에 감사 .

답변

1

보기 대신 Gamecontroller_ViewViewGroup을 확장하는 것이 좋습니다. 문서에서 :

뷰 그룹은 다른 뷰를 포함 할 수있는 특별한이다 ( 아이들을 불렀다.) 뷰 그룹은 레이아웃과 뷰 컨테이너의 기본 클래스입니다.