Android Question [SOLVED] How to implement Theme.MaterialComponents.DayNight ?

zolive33

Active Member
Licensed User
Longtime User
Hi,

I would like to use Material Design components for Android (https://material.io/).
In the manifest editor, I declare :
manifest.xml:
CreateResource(values-v25, theme.xml,
<resources>
    <style name="Theme.MyApp" parent="Theme.MaterialComponents.DayNight">
        <!-- ... -->
    </style>
</resources>
)

But I have an error when I build sample projet. I think I have checked everything, so I dont no why :(
Can anyone help me ? thanks in advance. ?

I add an example to test, and the list of installed components.
 

Attachments

  • smallProject.zip
    9 KB · Views: 277
  • installed-components.txt
    13.8 KB · Views: 271

zolive33

Active Member
Licensed User
Longtime User
thank you for your response, but I develop a library that uses new Material Components theme attributes.
So I can't use AppCompat themes.:(
 
Upvote 0

zolive33

Active Member
Licensed User
Longtime User
Finally I found the solution: I put "sdk manager" back in its original configuration.
I added the libraries "androidx.annotation:annotation-experimental" and "androidx.viewpager2:viewpager2". And now I can Build

Problem solved :)
 
Last edited:
Upvote 0

Spavlyuk

Active Member
Licensed User
Note that if you want to use newer versions of material components, you might need to manually install and modify dependencies. As far as I know, the sdk manager doesn't always let you install the newer dependencies.

For example, I've had to do that for constraintlayout 2.0.1, which is required for v1.3.0 of material components. You can download these from google maven, place them in your android skd folder under extras\b4a_remote and edit installed-components.txt to reflect the changes you made.

This should work for up to v1.4.0. For v1.5.0 you have to change the targetSdkVersion to 31, which I don't know if B4A supports at this point.
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
Finally I found the solution: I put "sdk manager" back in its original configuration.
I added the libraries "androidx.annotation:annotation-experimental" and "androidx.viewpager2:viewpager2". And now I can Build

Problem solved :)

Am interested, post example manifest and example project with the day/night
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
Upvote 0
Top