You could modify it simply like this
GradientDrawable bgShape = (GradientDrawable)btn.getBackground();
bgShape.setColor(Color.BLACK);
More Related Contents:
- Set android shape color programmatically
- Dynamic form with repeating form
- MonoDroid: Error when calling constructor of custom view – TwoDScrollView
- How can I programmatically include layout in Android?
- How to create custom button like the image
- What is the difference between gravity and layout_gravity in Android?
- Can the Android layout folder contain subfolders?
- Android How to adjust layout in Full Screen Mode when softkeyboard is visible
- Set the absolute position of a view
- How to put a border around an Android TextView?
- How to detect the swipe left or Right in Android?
- Android what does the clipToPadding Attribute do?
- Inflate a view / layout into another layout?
- How to show one layout on top of the other programmatically in my case?
- Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml
- android Multiple selection ListView & Textview
- Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
- ANDROID : split the screen in 2 equals parts with 2 listviews
- RecyclerView steals focus when inside a NestedScrollView
- How to use textview.getLayout()? It returns null
- How to add a switch to android action bar?
- Android Jetpack Compose width / height / size modifier vs requiredWidth / requiredHeight / requiredSize
- Items inside GridView getting repeated when screen scrolls
- custom dialog with close button
- How to create a marquee effect for a text of smaller length not exceeding the screen size in Android?
- How to overcome this item padding in navigation drawer?
- Placing ViewPager as a row in ListView
- Android WebView Scrollable
- EditText request focus
- Why isn’t there a getContentView() method for Activity?