Android - Google 地图上的透明切换按钮
我有一个非常简单的布局:RelativeLayout 带有 MapView 和 ToggleButton。当我没有指定它应该在任何地方时,为什么 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?
<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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须应用在其他地方定义的主题或样式。这不是默认的切换按钮样式。这是我的测试项目中几乎相同的 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:
I hope this is of some use.
我解决了这个问题,只是向 ToggleButton 标签添加样式:
我希望这可以帮助遇到同样问题的人。 :-)
I solved this problem just adding style to ToggleButton tag:
I hope this helps somebody with the same problem. :-)