0
我有一個自定義列表視圖和線性佈局與在屏幕底部的textview。我已經實現了一個OnScrollListener來在滾動時隱藏操作欄和線性佈局,並在滾動完成後返回。該Actionbar是隱藏順利沒有任何閃爍和口吃,但與linearlayout不是。我使用動畫來隱藏佈局,但我無法完全實現。我需要的佈局應該像twitter應用程序一樣隱藏底部佈局在滾動時平滑隱藏。請幫忙。在屏幕底部隱藏linearlayout,而列表視圖滾動
mViews.lists.setOnScrollListener(new AbsListView.OnScrollListener() {
int mLastFirstVisibleItem = 0;
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
android.support.v7.app.ActionBar actionBar = getSupportActionBar();
if (view.getId() == mViews.lists.getId()) {
final int currentFirstVisibleItem = mViews.lists.getFirstVisiblePosition();
if (currentFirstVisibleItem > mLastFirstVisibleItem) {
// getSherlockActivity().getSupportActionBar().hide();
if (actionBar != null) {
actionBar.hide();
mViews.linear.startAnimation(animHide);
mViews.linear.setVisibility(View.GONE);
}
} else if (currentFirstVisibleItem < mLastFirstVisibleItem) {
// getSherlockActivity().getSupportActionBar().show();
actionBar.show();
mViews.linear.startAnimation(animShow);
mViews.linear.setVisibility(View.VISIBLE);
}
mLastFirstVisibleItem = currentFirstVisibleItem;
}
}
});
隱藏和顯示XML:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<scale
android:fromYScale="1.0"
android:interpolator="@android:anim/linear_interpolator"
android:toYScale="0.0" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true" >
<scale
android:fromYScale="0.0"
android:interpolator="@android:anim/linear_interpolator"
android:toYScale="1.0" />
</set>