大佬教程收集整理的这篇文章主要介绍了android – 仅隐藏Scroll上的Action栏而不是操作栏选项卡,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
对于Eg:
我推荐了这个Tutorial.在这里你可以看到与隐藏相关的输出和相应代码并显示操作栏.
我正在展示我到目前为止得到的输出.
向下滚动后:
上面显示的屏幕截图,它也隐藏了操作栏标签.但是它必须只隐藏操作栏.这是主要问题.
向上滚动后:
TopRatedFragment.java:
import info.androidhive.tabsswipe.R; import android.app.ActionBar; import android.content.res.TypedArray; import android.os.bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.Window; import android.widget.ScrollView; public class TopRatedFragment extends Fragment implements ViewTreeObserver.onScrollChangedListener { private float mActionBarHeight; private ActionBar actionBar; @Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceStatE) { View rootView = inflater.inflate(R.layout.fragment_top_rated,container,falsE); final TypedArray styledAttributes = getActivity().getTheme().obtainStyledAttributes( new int[] { android.R.attr.actionBarSize }); mActionBarHeight = styledAttributes.getDimension(0,0); styledAttributes.recycle(); actionBar = getActivity().getActionBar(); ((ScrollView)rootView.findViewById(R.id.parent)).getViewTreeObserver().addOnScrollChangedListener(this); return rootView; } @Override public void onScrollChanged() { float y = ((ScrollView)getActivity().findViewById(R.id.parent)).getScrollY(); if (y >= mActionBarHeight && actionBar.isShowing()) { actionBar.hide(); } else if ( y==0 && !actionBar.isShowing()) { actionBar.show(); } } }
fragment_top_rated.xml:
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://scheR_824_11845@as.android.com/apk/res/android" android:id="@+id/parent" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="?android:attr/actionBarSize" android:orientation="vertical" > <Button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Button" /> <Button android:id="@+id/button5" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Button" /> . . </LinearLayout> </ScrollView>
我的问题是,向下滚动它只需要隐藏操作栏而不是操作栏选项卡.
以上是大佬教程为你收集整理的android – 仅隐藏Scroll上的Action栏而不是操作栏选项卡全部内容,希望文章能够帮你解决android – 仅隐藏Scroll上的Action栏而不是操作栏选项卡所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。