我尝试为Google Photo中体现的工具栏滚动行为。但是我的工具栏没有完全隐藏在状态栏下。
if(itLogger != mLoggerMap.end()){
return itLogger->second.get();
}
答案 0 :(得分:0)
查看此库Android-ObservableScrollView
Whatsapp使用相同的
答案 1 :(得分:0)
我使用此代码隐藏工具栏,您可以从下面的代码编写中获取帮助。
public class MainActivity extends AppCompatActivity implements ObservableScrollViewCallbacks{
@Override
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
}
@Override
public void onDownMotionEvent() {
}
@Override
public void onUpOrCancelMotionEvent(ScrollState scrollState) {
ActionBar ab = getSupportActionBar();
if (scrollState == ScrollState.UP) {
if (ab.isShowing()) {
ab.hide();
// image.setVisibility(View.GONE);
}
} else if (scrollState == ScrollState.DOWN) {
if (!ab.isShowing()) {
ab.show();
// image.setVisibility(View.VISIBLE);
}
}
}
ImageView image;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// image = (ImageView) findViewById(R.id.image);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ObservableListView listView = (ObservableListView) findViewById(R.id.list);
listView.setScrollViewCallbacks(MainActivity.this);
ArrayList<String> items = new ArrayList<String>();
for (int i = 1; i <= 100; i++) {
items.add("Item " + i);
}
listView.setAdapter(new ArrayAdapter<String>(
this, android.R.layout.simple_list_item_1, items));
}
}