Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

116
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda