LinearLayout
을 확장하고 onMeasure
함수를 덮어 쓰면 전체 레이아웃 크기 (화면 + 스크린 외부)를 반환하십시오. 이 코드는 시작하기 수
아닌 눈에 보이는 레이아웃으로이 레이아웃을 사용합니다 ..
public class YourLayout extends LinearLayout {
private Context myContext;
public YourLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
/*
* Magic!!! Android doesn't draw parts of layout which is offscreen. Since YourLinear layout has some offscreen part
* its offscreen portions didn't get drawn.
* This onMeasure function determines how much pixel of a layout need to be drawn.
* widthMeasureSpec -> Width of YourLayout onscreen
* heightMeasureSpec -> height of YourLayout on screen
* your_view_offscreen_width -> width of offscreen part
* your_view_offscreen_height-> height of offscreen part
* So heightMeasureSpec + your_view_offscreen_height draws complete height of YourLayout whether it is onscreen or offscreen.
* So widthMeasureSpec + your_view_offscreen_width draws complete width of YourLayout whether it is onscreen or offscreen
*/
super.onMeasure(widthMeasureSpec + your_view_offscreen_width, heightMeasureSpec + your_view_offscreen_height);
}
}
지금 당신이 아닌 눈에 보이는 레이아웃으로이 레이아웃을 사용할 수 있습니다 ... 즉, 당신이 할 수있는 당신에게 레이아웃 XML을 사용하는 경우 이런 식으로 사용하십시오
<com.your.package.YourLayout layout_width="fill_parent" layout_height="fill_parent"
......
>
감사합니다. Krishnabhadra! 그러나 그것은 제가 얻고있는 것이 아닙니다. 내가 "보이지 않는다"고 말할 때 나는 오프 스크린을 의미하지 않는다. 즉, 레이아웃이 다른 레이아웃 (즉, 표시된 레이아웃을 변경하기 위해 setContentView())에 의해 대체되었습니다. 나는 안드로이드 멍청 아 그래서 어쩌면 내가 잘못된 용어를 사용하고있다. – Batdude