2014-11-06 58 views
0

所以,我有一個的FrameLayout:FrameLayouts使用類似於層列表

<FrameLayout 
     android:id="@+id/btn" 
     android:layout_width="50dp" 
     android:layout_height="50dp" > 

     <ImageButton 
      android:id="@+id/b" 
      android:layout_width="50dp" 
      android:layout_height="50dp" 
      android:background="@drawable/background" /> 
     <ImageButton 
      android:id="@+id/bbtn" 
      android:layout_width="50dp" 
      android:layout_height="50dp" 
      android:background="@drawable/testcontur1" />   
    </FrameLayout> 

我不知道什麼是什麼把這個FrameLayout裏之間,這樣它會「採取行動」類似的第一層list.The層列表的例子是這樣的:

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

     <item android:id="@+id/backgr"> 
      <bitmap android:gravity="center" android:src="@drawable/background" /> 
     </item> 

     <item android:id="@+id/contur"> 
      <bitmap android:gravity="center" android:src="@drawable/testcontur1" /> 
     </item> 

</layer-list> 

所以,基本上,我需要做的就是以某種方式得到第一bitmap.This一個用Java參考:

<bitmap android:gravity="center" android:src="@drawable/background" /> 

但我無法管理這個,所以我想通過使用frameLayout並在其內部使用imagebutton(或imageview,無論)並通過它的ID獲取對它的引用來實現此目的的唯一方法。

我懷疑它可以幫助任何人,但我也會寫,我需要this.I需要按順序參照位/ ImageButton的能夠是這樣的:

reference.getBackground().mutate().setColorFilter(Color.RED ,PorterDuff.Mode.Multiply); 

任何幫助或想法上這將是非常棒的,因爲我從早上起就一直在努力實現這一目標,並且我無法獲得任何地方。

回答