问题描述
我在试图掩盖,而滚动down.Then而向上滚动操作栏得到一个问题,操作栏必须再次显示。
I am getting an issue at trying to hide the action bar while scrolling down.Then while scrolling up,the action bar have to shown again.
对于例如:
我提到这个Tutorial.Here你可以看到输出和各自的codes有关的隐藏和显示操作栏。
I referred this Tutorial.Here you can see the output and respective codes related to hide and show the action bar.
我显示在输出我得到它到现在。
I am showing the output what I get it till now.
向下滚动之后:
上面显示的屏幕截图,它隐藏动作栏选项卡also.But它必须只隐藏bar.That的重大问题上的行动。
The screenshot above shown, it hide the action bar tab also.But it have to hide only the action bar.That's the major issue.
滚动起来之后:
上面的截图显示它显示回来选项卡中的操作栏。
The screenshot above shows it displays back the action bar with tabs.
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://schemas.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>
我的问题是,虽然向下滚动,只需要隐藏操作栏不仅没有操作栏的标签。
My issue is, While scrolling down it only have to hide the action bar only not action bar tabs.
推荐答案
I think this library and its sample could help you.
看右上角的GIF动画:
Look at the top-right gif animation:
我觉得示例文件名为ViewPagerTabScrollViewActivity"
I think the sample file is called "ViewPagerTabScrollViewActivity"
这篇关于隐藏只有在不滚动操作栏选项卡上的操作栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!