-
Notifications
You must be signed in to change notification settings - Fork 265
ScrollView
Etienne Lawlor edited this page Feb 1, 2015
·
4 revisions
The example below demonstrates QuickReturn view as a footer in a ScrollView with a simple translate animation
public class QuickReturnFragment extends Fragment {
// region Member Variables
private QuickReturnViewType mQuickReturnViewType;
@InjectView(R.id.scroll_view)
NotifyingScrollView mNotifyingScrollView;
@InjectView(R.id.quick_return_header_tv)
TextView mQuickReturnHeaderTextView;
@InjectView(R.id.quick_return_footer_tv)
TextView mQuickReturnFooterTextView;
// endregion
//region Listeners
//endregion
// region Constructors
public static QuickReturnFragment newInstance(Bundle extras) {
QuickReturnFragment fragment = new QuickReturnFragment();
fragment.setRetainInstance(true);
fragment.setArguments(extras);
return fragment;
}
public QuickReturnFragment() {
}
// endregion
// region Lifecycle Methods
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_quick_return, container, false);
ButterKnife.inject(this, view);
return view;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
int headerHeight = getResources().getDimensionPixelSize(R.dimen.header_height2);
int headerTranslation = -(headerHeight);
int footerTranslation = getResources().getDimensionPixelSize(R.dimen.footer_height);
mQuickReturnFooterTextView.setVisibility(View.VISIBLE);
QuickReturnScrollViewOnScrollChangedListener scrollListener = new QuickReturnScrollViewOnScrollChangedListener.Builder(QuickReturnViewType.FOOTER)
.footer(mQuickReturnFooterTextView)
.minFooterTranslation(footerTranslation)
.build();
mNotifyingScrollView.setOnScrollChangedListener(scrollListener);
mNotifyingScrollView.setOverScrollEnabled(false);
}
@Override
public void onDestroyView() {
super.onDestroyView();
ButterKnife.reset(this);
}
// endregion
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.etiennelawlor.quickreturn.library.views.NotifyingScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="48dp"
android:id="@+id/scroll_view">
<include layout="@layout/scrollview_content"/>
</com.etiennelawlor.quickreturn.library.views.NotifyingScrollView>
<com.etiennelawlor.quickreturn.views.CustomFontTextView
android:id="@+id/quick_return_header_tv"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@color/transparent_black_ninty"
android:textSize="22sp"
android:layout_marginTop="48dp"
android:text="@string/header"
android:textColor="@android:color/white"
android:gravity="center"
android:visibility="gone"
app:textFont="Roboto_Bold"/>
<com.etiennelawlor.quickreturn.views.CustomFontTextView
android:id="@+id/quick_return_footer_tv"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@color/transparent_black_ninty"
android:textSize="22sp"
android:text="@string/footer"
android:textColor="@android:color/white"
android:gravity="center"
android:layout_alignParentBottom="true"
android:visibility="gone"
app:textFont="Roboto_Bold"/>
</RelativeLayout>