我正在开发一个Android应用程序,它有几个(Next,Back,...等)Buttons
这些都是圆形和透明的,我使用ImageButton
那些Buttons
,但问题是Button
(我使用黑色background
,因此它非常难看)上总是有一个白色边框,并且该按钮从未显示为圆形,表现为某种方形的形状。无法摆脱ImageButton周围丑陋的边框
这里是我试过到目前为止:
在
activity_mypage.xml
文件设置ImageButton
的背景android:background="@android:color/transparent"
,并
android:background="?android:selectableItemBackground"
和
android:background="?android:selectableItemBackgroundBorderless"
甚至
android:background="@null"
但似乎没有任何的.XML边工作。
,我试图在MyPage.java文件如下:
myBtn.setBackgroundResource(0);
也
myBtn.setBackground(null);
似乎没有任何工作对我所做不断产生相同的(尽管它从Button
附近删除灰色边框,但没有一个使得Button
完全透明)
而且这是同Button
截图应用任何这些属性(的并不重要,如果以后我申请它只是在xml
或仅java文件,或同时,因为所有的结果都是一样的):
这是在XML我Buttons
我的一个XML代码:
<ImageButton
android:id="@+id/my_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="26dp"
android:layout_marginEnd="37dp"
android:layout_marginRight="37dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:srcCompat="@mipmap/my_btn"
tools:layout_constraintBottom_creator="1"
tools:layout_constraintRight_creator="1"
android:background="@android:color/transparent"
/>
这里是在java文件它的代码:
ImageButton myBtn= (ImageButton) findViewById(R.id.my_btn);
myBtn.setBackground(null);
myBtn.setBackgroundResource(0);
我真的失去了在这个每个结果我发现这个查询已经提出的上述方法之一,但没有这些似乎为我工作..
看起来你的图像周围有白色边框。 –
你可以发布你的图像(my_btn)也 – UltimateDevil
@VivekMishra我曾尝试过一些透明的图像,但他们都有同样的问题,[这里](https://imgur.com/a/VZg3C)是这个链接我使用的相同图像。 –