내가 클리핑 문제에 대한 해결책을 찾을 수 없습니다 :
여기 내 테스트 레이아웃입니다.
// this call should be included in the onCreate method
// the post method is called after parentView is ready to be added
// so the parentView's height and width can be used
parentView.post(addSpace(parentView, myListView));
private Runnable addSpace(final RelativeLayout parent, final ListView list) {
return new Runnable(){
public void run() {
// create list adapter here or in the onCreate method
// R.layout.list_item refers to my custom xml layout file
adapter = new ArrayAdapter<String>(MainActivity.this, R.layout.list_item, values);
// calculate size and add header and footer BEFORE applying adapter
// listItemHeight was calculated previously
spacerSize = (parent.getHeight()/2) - (listItemHeight/2);
list.addHeaderView(getSpacer(), null, false);
list.addFooterView(getSpacer(), null, false);
list.setAdapter(adapter);
}
}
}
// I used a function to create my spacers
private LinearLayout getSpacer(){
// I used padding instead of LayoutParams thinking it would be easier to
// change in the future. It wasn't, but still made resizing my spacer easy
LinearLayout spacer = new LinearLayout(MainActivity.this);
spacer.setOrientation(LinearLayout.HORIZONTAL);
spacer.setPadding(parentView.getWidth(), spacerSize, 0, 0);
return spacer;
}
내가 할 수 있었다이 방법을 사용 : 내 ListView에의 상위 뷰 포스트 방법을, 내가 지금처럼 내 머리글과 바닥 글의 높이를 계산할 수 있었다 사용하여, 다음 match_parent하고 다시 내 ListView에 높이를 변경 내 ListView의 위쪽과 아래쪽에 적절한 간격을 추가하여 맨 위로 스크롤하면 내 항목의 가운데에 최상위 항목이 나타납니다.
문제 : 내 앱을 사용하면 부모가 훨씬 키가 커야하는 하단 인터페이스 요소를 숨길 수 있습니다. 내 머리글과 바닥 글을 동적으로 키를 만드는 방법을 찾고 있지만 단순히 ListView를 제거하고 더 큰 머리글과 바닥 글로 다시 만들어야 할 수도 있습니다.
나는 이것이 좌절의 시간에서 도움이되기를 바랍니다.