My button consists of only letters. Every time i press it, it has a black background. How do i disable the black background? I don´t want to change the color, i want to disable the pressed state.
Disable pressed background color of button
4.6k Views Asked by bruno At
2
There are 2 best solutions below
1
Jatin Malwal
On
Make a selector in drarable folder. It will be look like
`<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/button_pressed_yellow"
android:state_pressed="true" />
<item android:drawable="@drawable/button_focused_orange"
android:state_focused="true" />
<item android:drawable="@drawable/button_normal_green" />
</selector>`
Set this selector as a backgroung to the button. Now you can change in selector for all the states of button.
Related Questions in ANDROID
- Creating global Class holder
- Flutter + Dart: Editing name of a tab shows up a black screen
- android-pdf-viewer Received status code 401 from server: Unauthorized
- Sdk 34 WRITE_EXTERNAL_STORAGE not working
- ussd reader in Recket Native module
- Incorrect display of LinearGradientBrush in IOS
- The Binary Version Of its metadata is 1.8.0, expected Version is 1.6.0 build error
- I can't make TextInput to auto expand properly in Android
- Creating multiple instances of a class with different initializing values in Flutter
- How to create a lottie animation
- making android analyze with coverity sast tool
- Flutter plugin development android src not opening after opening example
- I initialize my ViewModel in the Activity with several fragments as tabs, but the fragments(tabs) return null for the updated livedata
- Node.js Server + Socket.IO + Android Mobile Applicatoin XHR Polling Error...?
- How I can use the shared preferences class?
Related Questions in BUTTON
- How to center fontawesome icons in a div?
- How can I eliminate or deactivate the white flash that appears when I press a button via a mobile device?
- React Node Telegram bot problem with mainButtonClicked
- Can I make this kind of radio button?
- Custom styled "Add to cart" button in WooCommerce product archive pages
- Have a script work multiple times with the same class
- How to "kill" current runnable and start a new one pressing a start/stop android button (and prevent multiple overlapping runnable processes)?
- How to customize woocommerce add to cart button position
- React: Implementing Long Press Button Functionality
- How to move expand button in bslib::card() where full_screen = TRUE to the top right?
- Why do I have to double click enter on Blazor?
- How to detect a pressed button using setInterval and without any event in javascript?
- Blogger next previous navigations missing
- How to make Scaffold floatingActionButton not clickable through
- How do I create a guizero pushbutton that acts when pressed and stops when released
Related Questions in COLORS
- Wrong matches between colors and values when defining colorFactor
- I want write code to predict CIE XYZ from LED driver R,G,B output value
- Finding a specific colour within a bitmap range - VB.net 2022
- In Flutter, is there a way to determine the user's skin color settings for their emojis?
- HDR video publishing
- make selected text visible in PGAdmin 4 Query Editor
- How to change x-axis group labels of my boxplot in R
- flutter stripe_android:verifyReleaseResources'. > A failure occurred while executing com.android.build.gradle.tasks > Android resource linking failed
- I would like a table where cells are colored (defined by values)
- Color Thresholding JS, Average Image Color Detect JS
- Assign visually distinct colors to graphs with undirected edges
- Change text color inside offcanvas navbar
- To set Different Colors For each line in Line Chart Using NPOI excel nuget package in .Net6 Core
- Is there a way to affect the interpolation between translucent colours in WPF?
- How to change the color of an icon when hovered over
Related Questions in STATE
- NextJS 13 14, Store server state globally
- My state is undefined despite being setted
- Next.js carousel component loads instagram basic display api perfectly except in Safari browser
- How can I create a javascript animation that recognizes when it hits things, in other words a hit box?
- Flutter - When an element is deleted from the ListView, the state of the element under deletion is reset
- State Transfer from a model using Riverpod flutter
- React components don't re render when the state is changed
- Flutter | Persisting Navigator State Using Hydrated Bloc with the Bloc Design Pattern
- Wait set state finishes to call another function
- keyboard focus with GTK4 Rust does not work as expected and how to get state
- Bind state to context value in React JS
- I have a problem when I run on the web Bad state: databaseFactory not initialized databaseFactory
- How to manage state in a chrome extension in this scenario
- Should I use immutable or mutable state for a JSON tree editor in Flutter?
- React Component doesn't change states until file is resaved, then runs both at same time
Related Questions in PRESSED
- Android - change image of ImageButton when pressed and release
- Python [Canvas]: Detect Mouse Button NOT pressed
- I don't want to change color of JButton when pressed
- Java Mouse Listener
- Do ExpandableListView list item "press" behaviors have to be wired up by the developer?
- Cocoa/Carbon: catch global hotkey when key is kept pressed (held down)
- ICS ListView background disabled when set onclicklistener
- Error in the pygame.key.get_pressed() method
- iOS : How to detect any key pressed when use a BT keyboard
- android: 2 overlapping buttons to show pressed states
- Image pressed button changing size
- QPushButton() should react as long as it is pressed
- Only use button every few seconds in Unity
- Disable pressed background color of button
- Custom action When Pressing 'back button' on a UINavigationController
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You need to create selector under drawable folder and set color or image over there for different sates of the button.
I have created one sample application for you and am pasting code snippet:
Code for button_selector.xml that contains selector code for button which you will need to put under drawable folder:
You will need to put no_box_selector and no_box pngs in drawable-hdpi or any drawable folders
Code for activity_main.xml that will be your main xml that contains only one button as of now:
Try implementing these things and let me know if you need any further assisstance.....
All the best!!!