2015-05-26 43 views
2

我有兩個圓形圖像我想重疊這兩個圖像,但第二個圖像重疊的第一個圖像的百分比!灰色圖像和藍色圖像是兩個單獨的圖像。我想要顯示在附圖中。圖像重疊的android中的圖像視圖

enter image description here

+0

你能後的你試了一下到目前爲止的代碼? – AlvaroSantisteban

+0

使用一層LayerDrawable作爲ClipDrawable – pskink

+0

但我不知道如何啓動.please提供示例它真的是一個簡單的例子。 –

回答

1

我已經在我們的項目中實現同樣的事情。請通過下面的代碼片段:

XML:

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

      <ImageView 
       android:id="@+id/imagegreenid" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:scaleType="fitCenter" 
       android:src="@drawable/clip_full_green_gauge" /> 

      <ImageView 
       android:id="@+id/imagewhiteid" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/clip_feil_empty_gauge" /> 
     </RelativeLayout> 

守則活動:

int total_percent = orininalScore * 100; 
int TOTAL_VALUE = 10000; 

ImageView img = (ImageView) findViewById(R.id.imagegreenid); 
ClipDrawable mImageDrawable = (ClipDrawable) img.getDrawable(); 
mImageDrawable.setLevel(total_percent); 
ImageView img1 = (ImageView) findViewById(R.id.imagewhiteid); 
ClipDrawable mImageDrawable1 = (ClipDrawable) img1.getDrawable(); 
mImageDrawable1.setLevel(TOTAL_VALUE - total_percent);