使用 GDK(或以其他方式),有没有办法显示类似于在 Glass 上连接到 WiFi 网络时显示的进度指示器?(显示屏底部的“旋转”线,有点像这个视频的结尾:https ://www.youtube.com/watch?v=g3ncmeGaKN0 )
谢谢!
使用 GDK(或以其他方式),有没有办法显示类似于在 Glass 上连接到 WiFi 网络时显示的进度指示器?(显示屏底部的“旋转”线,有点像这个视频的结尾:https ://www.youtube.com/watch?v=g3ncmeGaKN0 )
谢谢!
UPD 04.11.2014:
谷歌发布了Slider
——适合于此的 UX 组件。您应该更好地使用它而不是提取的项目。
我从 GlassHome.apk 中提取了 Google Glass 进度条并基于它创建了一个库项目:https ://github.com/pif/glass-progress-bar
存储库中的自述文件中描述了用法。
是的,每个人都还在等待一套功能齐全的 Glass Views。
更新:我也提取了 MessageDialog 。您可以在同一个库中找到它。
这非常接近,但颜色已关闭(蓝色/蓝绿色/其他颜色,而不是白色)。
style="?android:attr/progressBarStyleHorizontal"
示例(通过OkGlassFindACat):
<ProgressBar
android:id="@+id/someProgressBar"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminate="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
不过,我肯定还没有弄清楚如何覆盖该颜色。
我知道我迟到了,但这是我的版本:)
https://github.com/prt2121/glass-gdk-progressbar
在 gradle 文件中添加到您的项目
compile 'com.github.prt2121:ProgressBar:1.0@aar'
截屏:
改变颜色
app:progress_color="@android:color/holo_blue_bright"
谷歌使用Slider(全局 UX 组件)https://developers.google.com/glass/develop/gdk/slider解决了这个问题
GDK 会自动覆盖某些小部件的主题以提供适当的类似 Glass 的外观,例如TextView
. 对于尚未具有该主题的小部件,请在此处提交问题,以便我们对其进行跟踪。
我把上面的答案放在一起,为我的卡片列表加载器活动创建一个总体布局。这是布局文件card_scroll_with_progress_layout.xml
:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black">
<com.google.android.glass.widget.CardScrollView
android:id="@+id/card_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ProgressBar
android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminate="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
</FrameLayout>
然后在 onCreate 我得到进度条并将其设置为滚动:
View rootLayout = getLayoutInflater()
.inflate(R.layout.card_scroll_with_progress_layout, null);
mProgressBar = (ProgressBar)rootLayout.findViewById(R.id.progress_bar);
mProgressBar.setVisibility(View.VISIBLE);
mCardScrollView = (CardScrollView)rootLayout
.findViewById(R.id.card_scroll_view);
mCardScrollView.setAdapter(mAdapter);
setContentView(rootLayout);
稍后在我的加载程序回调中,我隐藏了进度条并激活了卡片滚动视图:
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
if (loader.getId() == mLoaderId) {
mAdapter.swapCursor(data);
mProgressBar.setVisibility(View.GONE);
mCardScrollView.activate();
}
}
这似乎可以很好地作为处理各种 json 加载到 GDK 中的卡片列表中的范例。
尝试使用项目中的ProgressBarzoom-in
。
我们遇到了类似的问题,并找到了一种适合我们的混合方法。我们使用上一篇文章中提到的标准进度条@patridge,并应用了Android Holo Colors提供的生成的 Holo 样式。
我们能够生成看起来与内置 GDK 版本非常相似的白色进度条图像、动画、图层和样式。您可以通过编辑 Holo Color 生成的 png 图像的大小来增加栏的高度以匹配 GDK。
您将需要在项目中包含生成的文件,但这是我们的主题之后的样子:
<style name="OurGlassTheme" parent="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen">
<item name="android:progressBarStyleHorizontal">@style/ProgressBarGlass</item>
</style>
<style name="ProgressBarGlass" parent="android:Widget.ProgressBar.Horizontal">
<item name="android:progressDrawable">@drawable/glass_progress_horizontal_holo_light</item>
<item name="android:indeterminateDrawable">@drawable/glass_progress_indeterminate_horizontal_holo_light</item>
<item name="android:minHeight">16dip</item>
<item name="android:maxHeight">16dip</item>
</style>
我知道这非常乏味,但是当@giladgo 已接受向 Glass 开发人员提交以提供 GDK 进度条时,它会让我们到达那里。