Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7582067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:20:53+00:00 2026-05-30T18:20:53+00:00

here’s my issue. I have defined custom themes and styles, so as to customize

  • 0

here’s my issue. I have defined custom themes and styles, so as to customize various Views, in the relevant .xml files. Here are some code extracts:

themes.xml:

...
<style name="Legacy" parent="android:Theme.NoTitleBar">
    <item name="android:buttonStyle">@style/Legacy.Button</item>
    ...
</style>

styles.xml:

...
<style name="Legacy.Button" parent="@android:style/Widget.Button">
    <item name="android:textColor">#ffffff</item>
    <item name="android:background">@drawable/button_selector_blue</item>
    <item name="android:textSize">15dp</item>
</style>

Let’s say I set my application’s theme to Legacy. If I use a Button in a layout, it will get my custom default parameters (white text, background is @drawable/button_selector_blue, etc).

Now let’s say I want to keep those parameters save for the text size: I’d like to have some buttons with a larger text size, which would be defined in an titleSize attribute in attrs.xml:

...
<attr name="titleSize" format="reference|dimension" />

and which value is set for each theme in my themes.xml file.

So my layout would contain something like:

<Button 
    android:id="@+idmyButtonId"
    android:drawableRight="@drawable/aDrawable" 
    android:text="@string/someText"
    android:textSize="?titleSize"
    android:layout_width="fill_parent" android:layout_height="wrap_content">
</Button>

When launching my app I get the following error:
java.lang.UnsupportedOperationException: Can’t convert to dimension: type=0x2

So it seems I cannot tweak custom styles using attributes – at least not this way. Is such a thing possible ? If not, what would you use to achieve such a result ?

I’d like to give the user the ability to select among different themes, so I can’t just define an additionnal ButtonWithLargeText style and directly use it in my layout.

Thanks for your help !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:20:55+00:00Added an answer on May 30, 2026 at 6:20 pm

    I finally got it to work. Instead of defining my titles’ size in attrs.xml, I used dimens.xml. So now the following works:

    <Button 
      android:id="@+idmyButtonId"
      android:drawableRight="@drawable/aDrawable" 
      android:text="@string/someText"
      android:textSize="@dimen/titleSize"
      android:layout_width="fill_parent" android:layout_height="wrap_content">
    </Button>
    

    While I get my regular text size (which I defined in my styles.xml) on the Button by using this:

    <Button 
        android:id="@+id/idRegularButton"
        android:text="@string/regularSizeText"
        android:layout_width="wrap_content" android:layout_height="wrap_content">
    </Button>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the issue I am having: I have a large query that needs
Here is a scenario: User installs .NET application that you have made. After some
Here is an example: I have a file 1.js, which has some functions. I
Here's a problem I ran into recently. I have attributes strings of the form
Here's my scenario - I have an SSIS job that depends on another prior
Here we go again, the old argument still arises... Would we better have a
I have just tried to save a simple *.rtf file with some websites and
Here's the basic setup: I have a thin bar at the top of a
Here is my persistence.xml : <?xml version=1.0 encoding=UTF-8?> <persistence xmlns=http://java.sun.com/xml/ns/persistence xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd version=1.0>
Here is my problem : I have a post controller with the action create.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.