Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

113
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda