Bitmap lookup = Bitmap.createBitmap(width, height, Bitmap.Config.ALPHA_8); 
// 
//  确保每个路径都有一个索引值
lookup.eraseColor(0xFF000000); 
 
Canvas canvas = new Canvas(lookup); 
Paint paint = new Paint(); 
 
//
paint.setAntiAlias(false); 
paint.setStyle(Paint.Style.FILL); 
 
for(int i=0;i<paths.size();i++) 
    { 
    paint.setColor(i<<24); 
// 颜色的alpha值0xXX000000 
    canvas.drawPath(paths.get(i), paint);  
    }

 其实呢在标准的api中是没有这个方法可以调用的,只能通过自己的算法实现

这里呢 是在画的每条线的点都作为一个索引值 然后取索引值就可以了

 

2.

public static void autoScaleTextViewTextToHeight(TextView tv) 
{ 
    final float initSize = tv.getTextSize(); 
    //get the width of the view's back image (unscaled)....  
    float minViewHeight; 
    if(tv.getBackground()!=null) 
    { 
      minViewHeight = tv.getBackground().getIntrinsicHeight(); 
    } 
    else 
    { 
      minViewHeight = 10f;//some min. 
    } 
    final float maxViewHeight = tv.getHeight() - (tv.getPaddingBottom()+tv.getPaddingTop())-12;// -12 just to be sure 
    final String s = tv.getText().toString(); 
 
    //System.out.println(""+tv.getPaddingTop()+"/"+tv.getPaddingBottom()); 
 
    if(minViewHeight >0 && maxViewHeight >2) 
    { 
      Rect currentBounds = new Rect(); 
      tv.getPaint().getTextBounds(s, 0, s.length(), currentBounds); 
      //System.out.println(""+initSize); 
      //System.out.println(""+maxViewHeight); 
      //System.out.println(""+(currentBounds.height())); 
 
      float resultingSize = 1; 
      while(currentBounds.height() < maxViewHeight) 
      { 
        resultingSize ++; 
        tv.setTextSize(resultingSize); 
 
        tv.getPaint().getTextBounds(s, 0, s.length(), currentBounds); 
        //System.out.println(""+(currentBounds.height()+tv.getPaddingBottom()+tv.getPaddingTop())); 
        //System.out.println("Resulting: "+resultingSize); 
      } 
      if(currentBounds.height()>=maxViewHeight) 
      { 
        //just to be sure, reduce the value 
        tv.setTextSize(resultingSize-1); 
      } 
    } 
}


以上是群里提出的解答方式 我并没有实际测 只是确实可行的