2012-07-30 9 views

답변

1
당신이 onSurfaceCreated (그것을 잡을) 거기 크기를 조정하려고 할 것이다

... 디스플레이 크기를 얻을 수

private class surfaceCallback implements SurfaceHolder.Callback 
{ 
    @Override 
    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) 
    { 
     if (holder == videoHolder) 
     { 
      Log.e(TAG, "video surfaceChanged: f: " + format + ", w: " + width + ", h: " + height); 

      //resize it here maybe? 
     } else 
     { 
      Log.e(TAG, "Unknown surface: f: " + format + ", w: " + width + ", h: " + height); 
      assert (false); 
     } 
    } 

    @Override 
    public void surfaceCreated(SurfaceHolder holder) 
    { 
     Log.e(TAG, "surfaceCreated"); 
    } 

    @Override 
    public void surfaceDestroyed(SurfaceHolder holder) 
    { 
     Log.e(TAG, "surfaceDestroyed"); 
    } 
} 

하나의 가능한 방법 ...

//measured android resolution 
    WindowManager win = (WindowManager) getApplicationContext().getSystemService(WINDOW_SERVICE); 
    Display d = win.getDefaultDisplay(); 
    Point measuredResolution = new Point(); 
    d.getSize(measuredResolution); //measuredResolution now holds actual size. 
+0

참조하고있는 경우 다음 단지에있는 display.i 구멍을 채우기 위해 할 부모 컨테이너 : 그렇지

android:layout_width="fill_parent"와 동일한 사용 Displaysize-200px를 얻으시겠습니까? – David

+0

버튼 크기를 알고있는 경우 그렇습니다. 그렇지 않으면 displaySize - button.getMeasuredWidth() 및 getMeasuredHeight()를 사용하십시오. – Shark

1

당신을 xml에서 이것을 정의합니까? 이 프로그래밍 한 후하지만 난 그래서 해달라고 버튼을 @Shark의 대답

+0

This. 하지만 어쨌든 당신은 그가 그것을 시도하기를 기대할 것입니다 ... – Shark

+0

아마도이 일을 시도 : public void class onCreate (...) {... Display display = getWindowManager(). getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight(); surfaceHolder.setFixedSize (width, height); ...} – David

관련 문제