Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
How to create a Theme instance in android

There are some methods in android, for example getColor of Resource class, which ask for a Theme parameter. I didn't find a way how to create a Theme instance and therefore don't know what to send to getColor method as a Theme. I know that null is an option but I prefer to understand what can I do with the parameter (the meaning of Theme parameter in getColor method)

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If you're just referencing fixed colors from resource xml you won't notice a difference.

However you can use getColor to reference a color selector too, for example:

color/singlecolor.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="?attr/colorPrimary" />
</selector>

In this case there's reference to themed style attribute colorPrimary.

  • if you pass null as theme you will receive value from your applications main theme
  • if you pass context.getTheme you will receive value from your activitys theme

Of course your activity needs to have a custom theme that has different colorPrimary than applications theme itself to notice the difference.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!