마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

SurfaceView분할해서 사용하고 싶은데요...

0 추천

현재는 화면을 세로고정시킨 상태에서, 위쪽 절반을 surface 크기로 지정해서 사용하는 중입니다.

 

이걸 위, 아래로 분할해서 양쪽 다 사용하고 싶은데요.

 

어떤식으로 수정하면 되는지 알려주셨으면 합니다.

 

public class SurfView extends SurfaceView implements SurfaceHolder.Callback
{
....
}

이걸 액티비티에서 받아서 

DisplayMetrics metrics = getResources().getDisplayMetrics();	   
m_nResolWidth = metrics.widthPixels;
m_nResolHeight= metrics.heightPixels;	

nRightMargin = 0;
nBottomMargin = m_nResolHeight / 2;

final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(m_nResolWidth, m_nResolHeight);
layoutParams.bottomMargin = nBottomMargin;
layoutParams.rightMargin = nRightMargin;

SurfView m_sfView = new SufView(this);
setContentView(R.layout.activity_main);
m_sfView.setLayoutParams(layoutParams);

layout = (RelativeLayout)findViewById(R.id.layout);
layout.addView(m_sfView);
final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(m_nResolWidth, m_nResolHeight);
layoutParams.bottomMargin = nBottomMargin;
layoutParams.rightMargin = nRightMargin;

SurfView m_sfView = new SufView(this);
setContentView(R.layout.activity_main);
m_sfView.setLayoutParams(layoutParams);

layout = (RelativeLayout)findViewById(R.id.layout);
layout.addView(m_sfView);

 

순서가 바꼇을수도 있긴 한데 기기해상도 얻어서 절반을 마진으로 잡아서 addview하는 형식이에요.

 

1000*1000의 해상도라 가정했을 때 (0.0)~(500.500)의 surfaceview와 (0.500)~(500.1000)의 surfaceview 이렇게 만들려면 어떤식으로 설정해줘야 하는지 알려 주시면 감사하겠습니다..^^

emerald (760 포인트) 님이 2015년 1월 8일 질문

2개의 답변

+1 추천
 
채택된 답변

구글링으로 찾아봤는데

We never intended to allow for multiple surface view.

https://groups.google.com/forum/?fromgroups=#!topic/android-developers/fQihJKLki7M

nicehee (73,100 포인트) 님이 2015년 1월 8일 답변
emerald님이 2015년 1월 9일 채택됨
+1 추천
제가 알기로는 SurfaceView는 한 번에 한 개만 쓸 수 있습니다.

SurfaceView를 화면 전체 크기로 잡고 절반씩 나눠서 처리하면 될 것 같아요.
익명사용자 님이 2015년 1월 8일 답변
...