0

How to set android:foreground drawable of a button borderless in Android development? Like in case of android:background="?android:attr/selectableItemBackgroundBorderless".

hata
  • 11,633
  • 6
  • 46
  • 69
  • does...setting `android:foreground` not work? what happens when you do that, and what, specifically, did you expect to happen? – Ryan M May 27 '20 at 00:33

1 Answers1

1

Well you can use multiple approches

1. android:background="@android:color/transparent"

2. android:background="?android:attr/selectableItemBackground"

3. style="?android:attr/borderlessButtonStyle"

or

4. android:background="@drawable/btn_borderless" 

in 4th approch you will require a xml file btn_borderless in your drawable folder such as

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
</shape>

I got this answer from https://inducesmile.com/android-programming/how-to-create-borderless-button-in-android/

and your question may be possible duplicate of How to create borderless button using style from style.xml file (along with all other styles)

Prathamesh
  • 1,064
  • 1
  • 6
  • 16
  • In the question, I have asked if we can make foreground of the button borderless, while in answer it shows about background of the button. Prathamesh, can you please check. – Aiyan Hamid May 24 '20 at 15:51
  • Is there a way in which we can set android:foreground of button which doesnot have limit on border. – Aiyan Hamid May 24 '20 at 16:13
  • Let me try some of the things i found ,if they apply to your problem i will update my answer, by the way i have found that android:foreground="?attr/selectableItemBackground" can also be applicable – Prathamesh May 24 '20 at 16:48
  • Problem with applying android:foreground="?attr/selectableItemBackgroundBorderless" is, even though my button background was oval when applying ripple on button it shows the rectangular edges. – Aiyan Hamid May 24 '20 at 17:34
  • well then try adding the code in the 4th approach of my answer just replace the "rectangle" with "oval" – Prathamesh May 24 '20 at 18:05