2012-04-03 66 views
1

我已將ImageView,SurfaceView和控制元素覆蓋爲ImageView的框架佈局。因此,使用SurfaceView播放MediaPlayer媒體,然後使用ImageView然後MediaPlayer將媒體準備爲靜止圖像。然後在準備ImageView與靜止圖像setVisibility - GONE和我們播放視頻。問題出在控制ImageViews。因爲他們一個PNG圖像與透明圖形,然後覆蓋在透明區域上看起來不錯,但MediaPlayer播放視頻,透明區域的圖形看起來非常有色,我們禁用此控件...android:圖像作爲帶有MediaPlayer的SurfaceView透明度的按鈕

請幫我建議如何使控件看起來相同覆蓋ImageViewSurfaceView

<?xml version="1.0" encoding="utf-8"?> 
<merge xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/FrameLayout" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

<SurfaceView 
    android:id="@+id/svMain" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" /> 

<ImageView 
    android:id="@+id/ivMain" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:scaleType="fitXY" 
    android:src="@drawable/still_image" /> 

<RelativeLayout 
    android:id="@+id/controls" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:gravity="bottom" > 

    <ImageView 
     android:id="@+id/ibtnStart" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:clickable="true" 
     android:onClick="ibtnClick" 
     android:src="@drawable/start_image" /> 

    <ImageView 
     android:id="@+id/ibtnStop" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:clickable="true" 
     android:onClick="ibtnClick" 
     android:src="@drawable/stop_image" /> 

</RelativeLayout> 

</merge> 
+0

你有沒有找到解決這個問題呢?我一直有相同的問題相當長一段時間沒有解決... – 2013-01-18 20:44:18

回答

0

我不知道多少,這會有所幫助,但你可以使用

controls.setColor(Color.argb(00, 0, 0, 0)); 

第一個參數表示負責transperency alpha值嘗試設置控件的背景色。塞提特00 值範圍爲00-255

+0

不幸的是,也沒有幫助太.. – wizemanold 2012-04-03 17:35:52

+0

也許如果你可以上傳一個現在是如何的屏幕截圖,我們可以更好地瞭解你想要什麼... – Ajay 2012-04-04 17:26:40

+0

奇怪,但我無法在MediaPlayer正在播放SurfaceView時進行正常的屏幕截圖,只有我的控件在一個空白屏幕上。 – wizemanold 2012-04-05 05:40:37

0

你可以試試:

ImageView logo = (ImageView) findViewById(R.id.logo); 
logo.setAlpha(110); 
+0

這沒有幫助,整個圖像現在透明,但又覆蓋了SurfaceView和ImageView看起來不一樣。 ..也許MediaPlayer使用了一些其他的Alpha混合比ImageView? – wizemanold 2012-04-03 17:23:14