我在Android应用的home.xml中制作了一个静态页脚,但是我想为这个应用程序设置页脚,而不是制作导航抽屉,只有在上下滚动后才能看到。
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
android:layout_weight="1"
android:background="@color/white"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginLeft="15dp"
android:id="@+id/back_to_previous"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:clickable="true"
android:src="@drawable/selector_footer_services" />
<com.gaadizo.gaadizo_user.ui.CustomTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/back_textdf"
android:hint="Services"
android:textColorHint="@color/footer_text_inactive"
android:textSize="@dimen/_13sdp"/>
</LinearLayout>
答案 0 :(得分:0)
将滚动更改侦听器添加到ScrollView,然后在onScrollChanged方法中管理页脚的可见性。找到下面的示例代码
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
View view = (View) getChildAt(getChildCount()-1);
int diff = (view.getBottom()-(getHeight()+getScrollY()));
if( diff <= 0 ){
yourFooter.setVisibility(View.GONE);
}
else{
yourFooter.setVisibility(View.VISIBLE);
}
super.onScrollChanged(l, t, oldl, oldt);
}