[英]Making a button transparent Android?
How do I get rid of the white bit around the button? 如何摆脱按钮周围的白点? I don't want the button transparent, but I want the white bit around it.
我不希望按钮透明,但是我希望按钮周围有白色。 I've got Google Maps behind the button.
我的按钮后面有Google地图。
I've tried android:background="@android:color/transparent", on the Button, but it's only the button that becomes transparent (not the white bit around it). 我已经尝试了Button上的android:background =“ @ android:color / transparent”,但这只是使按钮变得透明的按钮(而不是周围的白点)。
How do I do this in XML? 如何在XML中做到这一点?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MyLocation" >
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@android:color/transparent"
android:gravity="center" >
<Button
android:id="@+id/filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="filterMenu"
android:text="@string/filter_button" />
</FrameLayout>
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</LinearLayout>
How about setting the background of RelativeLayout
to transparent? 如何将
RelativeLayout
的背景设置为透明?
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent" >
<Button
android:id="@+id/filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:onClick="filterMenu"
android:text="@string/filter_button"
/>
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
And why not using FrameLayout
anyway? 为什么不使用
FrameLayout
? It's better in performance than RelativeLayout
. 它的性能比
RelativeLayout
更好。
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:background="@android:color/transparent" >
<Button
android:id="@+id/filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="filterMenu"
android:text="@string/filter_button"
/>
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</FrameLayout>
try this: 尝试这个:
MybuttonName.getBackground().setAlpha(0); MybuttonName.getBackground()setAlpha(0)。
0= Completely transparent. 0 =完全透明。 255 Completely opaque.
255完全不透明。
How about this. 这个怎么样。
Button filter = (Button) findViewById(R.id.filter);
filter.setBackgroundColor(Color.TRANSPARENT);
尝试这个
android:background="@android:color/transparent"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.