【问题标题】:How to get a round image button in android studio如何在android studio中获得圆形图像按钮
【发布时间】:2016-09-24 16:02:00
【问题描述】:

我试图获得一个圆形的图像按钮。但它显示的是带有方形背景的圆形图像,但我只需要没有任何背景的图像。 我还使用round_image.XML 作为背景可绘制文件,但它不起作用。

menu.xml

<ImageButton
android:id="@+id/imageButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true"      android:src="@drawable/sliderr" android:background="@drawable/round_image"/>

round_image.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="oval">
<gradient android:startColor="#50d050                                       
android:endColor="#008000" android:angle="270"/>
<stroke 
android:width="1px"
 android:color="#000000"/>
</shape>

【问题讨论】:

标签: android-studio android-imagebutton


【解决方案1】:

使用这个角落,而不是你的

 <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="@color/colorPrimary" />
    <stroke android:color="@color/colorPrimary" />
    <corners
        android:bottomLeftRadius="5dp"
        android:bottomRightRadius="5dp"
        android:topLeftRadius="5dp"
        android:topRightRadius="5dp" />
</shape>

【讨论】:

  • 我认为您使用图像 src ,因此您设置的背景将被图像 src @RohithaAgina 覆盖
猜你喜欢
  • 1970-01-01
  • 2016-05-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-19
  • 1970-01-01
  • 2012-04-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多