Hello,
The style on this component requires your app theme to be Theme.AppCompat
NavigationRailView
is a kind of Material control. The Material control is used in the xml layout, so the android:theme
style of the Application or activity must be Theme.AppCompat
or its sub-styles.
Solution:
Apply the theme in your Android project, or you could implement your own theme as follows:
<style name="MyTheme" parent="@android:style/Theme.Material.Light.NoActionBar">
... <!--Add the colors of the following three names (the color value is arbitrary), and the style of MyTheme satisfies Theme.AppCompa, and you could solve the above problem-->
<item name="colorPrimary">#ffff00</item>
<item name="colorPrimaryDark">#ff00ff</item>
<item name="colorAccent">#ff0000</item>
</style>
After that you need to add the style to the AndroidManifest.xml
.
As a complement, NavigationRailView often needs to be used in combination with other components, so it is not recommended to create objects directly in C#. Please refer to NavigationRailView for more details.
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.