Android - Google 地图上的透明切换按钮

发布于 2024-12-10 08:51:42 字数 1113 浏览 7 评论 0原文

我有一个非常简单的布局:RelativeLayout 带有 MapView 和 ToggleButton。当我没有指定它应该在任何地方时,为什么 ToggleButton 显示为透明,真正的问题是,我怎样才能让它停止?

Transparent ToggleButton

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<com.google.android.maps.MapView
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="NoYouCantSeeMyKey" />

<ToggleButton android:id="@+id/aerialsbutton"
    android:layout_width="150px"
    android:layout_height="50px"
    android:textOn="Aerials On"
    android:textOff="Aerials Off"
    android:layout_alignParentRight="true" />

</RelativeLayout>

我尝试将 alpha 设置为 1 并切换 MapView 和 ToggleButton 的顺序,但没有成功。非常感谢任何帮助。

更新:我将我的应用程序主题设置为 android:theme="@android:style/Theme.Holo.NoActionBar"。这有关系吗?

更新2:主题没有区别。这里很困惑。

I have a very simple layout: RelativeLayout with a MapView and a ToggleButton. Why is the ToggleButton showing up transparent when I didn't specify it should anywhere, and the real question, how can I make it stop?

Transparent ToggleButton

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<com.google.android.maps.MapView
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="NoYouCantSeeMyKey" />

<ToggleButton android:id="@+id/aerialsbutton"
    android:layout_width="150px"
    android:layout_height="50px"
    android:textOn="Aerials On"
    android:textOff="Aerials Off"
    android:layout_alignParentRight="true" />

</RelativeLayout>

I've tried setting alpha to 1 and switching the order of MapView and ToggleButton with no luck. Any help is much appreciated.

UPDATE: I have my Applcation theme set to android:theme="@android:style/Theme.Holo.NoActionBar". Could that matter?

UPDATE 2: The theme makes no difference. Pretty stumped here.

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

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

发布评论

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

评论(2

泛泛之交 2024-12-17 08:51:42

您必须应用在其他地方定义的主题或样式。这不是默认的切换按钮样式。这是我的测试项目中几乎相同的 xml 的屏幕截图的一部分 - 这显示了默认的切换按钮:

我希望这有一些用处。

You must have a theme or a style applied to it which is defined somewhere else. That's not a default toggle button style. Here's a portion of a screen capture of a nearly identical xml in a test project of mine - this shows the default toggle button:

enter image description here

I hope this is of some use.

末蓝 2024-12-17 08:51:42

我解决了这个问题,只是向 ToggleButton 标签添加样式:

 <ToggleButton 
    android:id="@+id/my_toggle_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textOn="@string/toggle_button_on"
    android:textOff="@string/toggle_button_off"
    style="@android:style/Widget.Button.Toggle"/>

我希望这可以帮助遇到同样问题的人。 :-)

I solved this problem just adding style to ToggleButton tag:

 <ToggleButton 
    android:id="@+id/my_toggle_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textOn="@string/toggle_button_on"
    android:textOff="@string/toggle_button_off"
    style="@android:style/Widget.Button.Toggle"/>

I hope this helps somebody with the same problem. :-)

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