在操作栏进度 [英] ProgressBar under Action Bar
问题描述
问摘要:我怎样才能让一个进度
集成在动作条
,像Chrome应用?
Question Summary: How can I make a ProgressBar
integrated inside the ActionBar
, like on the Chrome App?
详细信息:看看这张截图来自Chrome浏览器:
Details: Look at this screenshot from Chrome:
我想创建一个操作栏,就像这样。刚下操作栏,有一个进度条,根据页面加载罢了。我已经看到了这个例子从许多应用程序,像Feedly,但我一直没能创造我自己的实现。我试图使用Android的自己的API来创建它:
I want to create an Action Bar just like this. Just under the Action Bar, there's a ProgressBar that fills according to page load. I've seen this example from many apps, like Feedly, but I haven't been able to create my own implementation. I tried using Android's own APIs to create it:
@Override
protected void onCreate(Bundle savedInstanceState) {
//Request Permission to display the Progress Bar...
this.requestWindowFeature(Window.FEATURE_PROGRESS);
this.setWindowContentView(R.layout.activity_main)
super.onCreate(savedInstanceState);
this.setProgressBarIndeterminate(true);
}
但是,这code只能导致进度条显示的在的操作栏,如下所示:
But this code only causes the ProgressBar to show over the Action Bar, like so:
所以,我怎么能下的操作栏我的进度条出现,就像在Chrome应用程序?
So, how can I make my ProgressBar appear under the Action Bar, like on the Chrome App?
推荐答案
这是目前可以使用的 SwipeRefreshLayout 。
你可以用你的滚动视图使用 SwipeRefreshLayout
,然后你只需要听的 onRefresh 的事件:
You can wrap your scrollable view with a SwipeRefreshLayout
and then you just need to listen to onRefresh events:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
swipeLayout.setOnRefreshListener(this);
swipeLayout.setColorScheme(android.R.color.holo_blue_bright,
android.R.color.holo_green_light,
android.R.color.holo_orange_light,
android.R.color.holo_red_light);
}
@Override public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override public void run() {
swipeLayout.setRefreshing(false);
}
}, 5000);
}
有一个很好的和简单的教程可以在这个博客被发现。
A nice and simple tutorial can be found in this blog.
这篇关于在操作栏进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!