0

I want to make section background part A white

and part B, which is gray in color

Make it black No matter what I did, I could not part B change its color

I searched the sites and did not find anything Thank you for helping me

  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Aug 18 '23 at 08:24

1 Answers1

0

You can set a background for the navigation bar by customizing the theme of your app. Ref. Link

Option1:

  • Navigate to your app's res/values/styles.xml file

  • Create a new style or modify an existing one to customize the navigation bar's background. Use the android:navigationBarColor attribute to set the background color.

     <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
     <!-- Other theme attributes -->
    
     <!-- Set the navigation bar background color -->
     <item name="android:navigationBarColor">@color/navigation_bar_color</item>
     </style>
    

Apply your custom theme to your app or specific activity in the AndroidManifest.xml file:

<application
android:theme="@style/AppTheme">
<!-- Other application attributes -->
</application>

Option2:

For a gradient background with two different colors for the navigation bar.

  • Create a Gradient Drawable Resource:

     <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
     <item>
         <shape>
         <gradient
             android:type="linear"
             android:startColor="#FF0000" <!-- First color -->
             android:endColor="#00FF00" <!-- Second color -->
             android:angle="90" /> <!-- Gradient angle -->
     </shape>
     </item>
     </layer-list>
    
  • Apply Gradient Background Programmatically in Activity's onCreate method.

     // Get the window object
     val window: Window = window
    
     // Set the navigation bar gradient background
     window.navigationBarColor = ContextCompat.getColor(this, android.R.color.transparent) // Make navigation bar transparent
     window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) // Enable system bar backgrounds
     window.navigationBarBackground = resources.getDrawable(R.drawable.gradient_navbar_background, null)
    
harsh bangari
  • 417
  • 6
  • 19