Android 按钮栏切换

发布于 2024-08-21 09:19:17 字数 303 浏览 2 评论 0原文

我正在寻找一个模仿功能的 UI 视图 Google 地图方向屏幕 UI 控件允许用户 选择允许的路线类型,汽车、公交或步行。

像这样--> http://snapplr.com/50rh

该小部件本质上是水平布局的三个按钮 圆角仅在第一个按钮的左侧和第三个按钮的右侧。

我看不到执行此操作的标准方法,尽管看起来会 是一个普通的小部件。是否有其他一些标准的方式来呈现 水平布局中的多选分组作为“单一”布局 目的。

I am looking for a UI view that imitates the functionality of the
Google Maps directions screen UI control where it allows the user to
pick the type of directions allowed, either Car, Transit or Walking.

Like this --> http://snapplr.com/50rh

The widget is essentially three buttons laid out horizontally with
rounded corners only on the left of the first and right of the thirdbutton.

I can't see a standard way to do this, although it seems like it would
be a common widget. Is there some other standard way of presenting a
multi-choice grouping in a horizontal layout as a "single" layout
object.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

香草可樂 2024-08-28 09:19:17

我不知道 Android SDK 中有按钮栏小部件。您可以在 LinearLayout 中使用 ImageButtons 创建一个,并为所有内容提供自定义背景(以提供光泽黑色外观、处理不同的角集以及处理选定与非图像)。然后,您需要添加切换智能,这样按下一个按钮即可使其被选中,而布局中的其他按钮则未被选中。

如果您希望坚持使用更简单的现有小部件,SpinnerRadioButtonToggleButton 将是最有可能的候选者。

I am not aware of a button bar widget in the Android SDK. You would create one with ImageButtons in a LinearLayout, with custom backgrounds for all (to give the gloss-black look, to handle the varied sets of corners, and to handle the selected vs. not imagery). You would then need to add the toggling smarts, such that pushing one makes it selected and makes the others in the layout not selected.

If you wish to stick to simpler existing widgets, Spinner, RadioButton, or ToggleButton would be the most likely candidates.

年少掌心 2024-08-28 09:19:17

我认为没有内置的方法可以做到这一点。我可以想到两种方法来实现它。第一个是为 TabWidget 创建自定义样式。第二种是创建您自己的自定义小部件。制作 TabWidget 样式可能会更灵活,因为您可以轻松返回并添加或删除选项卡,并且它会相应更新。制作您自己的自定义小部件将使您能够更好地控制小部件的外观和行为。所以你真的需要看看什么最适合你想做的事情。

I don't think there is a built-in way to do it. I can think of two ways to accomplish it. The first would be to create a custom style for the TabWidget. The second would be to create your own custom widget. Making a TabWidget style might be more flexible because you could easily come back and add or remove tabs and it would update accordingly. Making your own custom widget would give you much more control over how the widget looks and acts. So really you need to see what would be the best fit for what you're trying to do.

も星光 2024-08-28 09:19:17

我发现的最好的按钮栏: http://androidworkz.com/2011/02/04/custom-menu-bar-tabs-how-to-hook-the-menu-button- to-showhide-a-custom-tab-bar/

它被认为可以用作菜单的替代品,但我相信它对于自定义按钮栏也很棒。实际上我会立即将它集成到我的应用程序中:-)

感谢原作者 androidworkz。

Best button bar I've found: http://androidworkz.com/2011/02/04/custom-menu-bar-tabs-how-to-hook-the-menu-button-to-showhide-a-custom-tab-bar/

It's thought to be used as a replacement for the menu, but I believe it's also great for a custom button bar. I'm actually gonna integrate it in my app straight away :-)

Kudos for androidworkz, the original author.

夜深人未静 2024-08-28 09:19:17

我认为电源控制小部件可以满足您的要求。查看该小部件的源代码,它使用了 LinearLayouts 和 LinearLayouts 的组合。 ImageViews来实现布局。

布局文件:https:// /android.googlesource.com/platform/packages/apps/Settings/+/froyo-release/res/layout/widget.xml

源代码:https://android.googlesource.com/platform/packages/apps /Settings/+/froyo-release/src/com/android/settings/widget/SettingsAppWidgetProvider.java

I think the power control widget does what you want. Looking at the source for the widget, it uses a combination of LinearLayouts & ImageViews to achieve the layout.

Layout file: https://android.googlesource.com/platform/packages/apps/Settings/+/froyo-release/res/layout/widget.xml

Source code: https://android.googlesource.com/platform/packages/apps/Settings/+/froyo-release/src/com/android/settings/widget/SettingsAppWidgetProvider.java

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文