Style does not work on Button

Here is my XML for a Button:

  android:text="Some text"

And here is the style XML for the Button:

<?xml version="1.0" encoding="utf-8"?>
    <style name="Btest" parent="@android:style/Widget.Button">
        <item name="android:textColor">#FFFFFFFF</item>
        <item name="android:textSize">16dip</item>
        <item name="android:textStyle">bold</item>

But, the style XML has no effect on the Button. If I skip the style XML and apply the style directly in the Button XML, things work as intended.

What am I missing?

Asked by: Blake534 | Posted: 25-01-2022

Answer 1

Are you using the parent="@android:style/Widget.Button" for a particular reason? You only need to specify a parent when you want to inherit from another style. What happens if you remove this?

Answered by: Marcus289 | Posted: 26-02-2022

Similar questions

Android button bar toggle

I am looking for a UI view that imitates the functionality of the Google Maps directions screen UI control where it allows the user to pick the type of directions allowed, either Car, Transit or Walking. Like this --> The widget is essentially three buttons laid out horizontally with rounded corners only on the left of t...

android - How to get rid of the extra gap between a button and other views?

When I created a button view, Android always create some extra space between this button and other views below it. In this example below, there is a button above the second button. You can see the gap between these two buttons. How can I get rid of this gap? Thanks. &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="" android:or...

button - Same Title Bar but different View below it in Android?

In one of my Android Application I need to keep the title bar same but the view that is shown in the rest of the screen changes. So, I have taken different Activity for all the views that I need to show and set the title bar in every Activities onCreate method. Now, the problem is that I have a button in the title bar and need to perform certain action on its click event. Writing the same event handling code in eve...

how to add a button in android?

I am new to android. Tell me how to add a button in android. And when we clicks on it it has to do a activity

icons - Android Image Button Issue

I have the following imageButton &lt;ImageButton android:id="@+id/header_buttonleft" android:layout_width="40dip" android:layout_height="40dip" android:layout_alignParentLeft="true" android:layout_marginLeft="10dip" android:layout_marginTop="5dip" android:src="@drawable/icon_download" android:clickable="true"/&gt; But when I load my application in the de...

java - Set width of Button in Android

How can I set a fixed width for an Android button? Everytime I try to set a fixed width it fills the current parent (the RelativeView). Here is my XML: &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout android:id="@+id/relativelayout" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android=""&gt; &lt;EditText android:...

java - Android : Cannot cast from View to Button

I just started working with the Android, but seem to have come across a problem that I simply can't find the answer to. I get the error "Cannot cast from View to Button" on this line : Button myButton = (Button)findViewById(; I've tried many different things to get it going, and I've searched for the answer, but for some reason it just refuses to work right. If anybody cou...

Android button font size

I;ve been trying to create a custom button in android using this tutorial - It works well but it doesn't say how to change the font size or weighting. Any ideas? There was another question on here and the only answer was to use html styling but you can't change a font size in html without using css (or t...

android - digital compass problem

I am creating an augmented reality application and I noticed that the stored locations don't appear appear on the correct direction if I try to use the camera view (using layar or wikitude API). The problem is that the digital compass doesn't show north correctly when you try to look at the known objects through the camera view. If align the phone with the ground (look at my shoes) the locations appear at the screen accord...

android - How to remove labels from a MapView?

I am trying to make a satellite view (via a MapView) without labels. How can I do this?

android - Custom title with image

i'm creating custom title for activity by disabling standard one and managing everything myself. I wonder if it's possible to replace/theme standart title to my needs. I can customize size, background image, and text via themes by changing windowXYZStyle items. The only thing i couldn't find - how i can add image instead of text. I've tried requestWindowFeature(Window.FEATURE_CUSTOM_TITLE) and ...

canvas - Android draw with blur

I need do draw on Android's Canvas using Blur effect, it is a very simple feature, I need to draw a circular area, which is blurred (the foreground) and the background transparent, I can do everything with manipulating the colour alpha to do it with custom transparency but I need it to be blurred instead of transparent.. any ideas?

layout - How to resize a android webview after adding data in it

In a layout (linear, vertical) hierarchy I've got several views and one of them is a WebView. They all have same parameters: android:layout_width="fill_parent" android:layout_height="wrap_content" For all views, the spacing between elements is correctly handled but for the Webview there is a lot of spaces after the displayed text inside. I set the (HTML) text of the webview in the ...

How to find easily the source of an android class

I know I can access android source code from, but it's hard to select the right git repo if I only know the package and the name of an android class. Isn't there a way to locate a file in

camera - Android Intent Save Path

At the moment I am using two intents. One for voice-recording, another for the camera: Intent photoIntent = new Intent(""); startActivityForResult(photoIntent, ACTIVITY_TAKE_PHOTO); Intent voiceIntent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION); startActivityForResult(voiceIntent, ACTIVITY_RECORD_SOUND); My aim is to put an Extra to each of t...

Android "hover" event in custom layout

I have a custom layout that I have written that basically just displays a bunch of ImageViews. I am handing onTouch events for all the ImageViews in my layout. However, if a user touches one imageView and then drags over another ImageView, I would like to be able to handle that as well. How would I go about capturing this behaviour?

android - What is the ideal place to cache images?

I am fetching a lot of thumbnails in my application from a remote server and lazy-loading these in a list view. The image fetches run in a background AsynTask and when completed the fetched images are stored in a HashMap using SoftReferences. This works just fine but when the images in the cache gets GC’d, the fetches have to be rerun. I could have stored them on the SD card so there would be no...

How to create a tree view in Android?

There are no controls in Android that provide Tree-like View. There is an ExpandableList View which I suspect could be used to creating one. Have you tried imlpementing such a control? How would one implement such a control in Android?

Still can't find your answer? Check out these communities...

Android Google Support | Android Community | Android Community (Facebook) | Android