Xin chào, tôi hiện đang làm việc trên Trò chơi có chứa VIEW hình ảnh hóa hiệu ứng tần số âm thanh trong nền của SurfaceView.Làm cách nào để thêm chế độ xem làm nền cho SurfaceView?
The surfaceView contains actual game play.
tôi đăng một số đoạn mã: -
main.xml
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#000" >
<co.ardor.visualizer.VisualizerView
android:id="@+id/visualizerView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</co.ardor.visualizer.VisualizerView>
</FrameLayout>
Visualizer view
được tạo ra như sau -
public class VisualizerView extends View
{
private static final String TAG = "VisualizerView";
private byte[] mBytes;
private byte[] mFFTBytes;
private Rect mRect = new Rect();
private Visualizer mVisualizer;
private Set<Renderer> mRenderers; // type of Renderer class
private Paint mFlashPaint = new Paint(); // for flash paint
private Paint mFadePaint = new Paint(); // for fade paint
public VisualizerView(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs);
init();
}
public VisualizerView(Context context, AttributeSet attrs)
{
this(context, attrs, 0);
}
public VisualizerView(Context context)
{
this(context, null, 0);
}
// Some code regarding to the audio visualization..
}
VisualizerView My chạy tốt vậy làm thế nào tôi có thể thêm này làm nền để SurfaceView (thực tế chạy game) .Tôi đang bị mắc kẹt trên các vấn đề mà "How to add VIEW as background of surfaceView?"
Hoặc bất kỳ một giải pháp tốt hơn cho điều đó .. Thx trước ..
xem không thể được thêm vào như là nền. Bạn phải đặt chế độ xem nội dung hoạt động của mình là – Blackbelt