Android custom theme won't apply - android-studio

For my application I want to make a custom theme with just a different color for my actionbar. So I found a theme generator on the Internet:'Android Action Bar Style Generator'. I picked some color and downloaded the theme, put my downloaded stuff in the res-folder and changed the 'style' to my new theme. For some reason my theme never applies to my application. It always uses the baseTheme which is also specified in the downloaded theme. This is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jobslot.indupac" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="#mipmap/bpi_logo_transparant_background"
android:label="Indupac"
android:theme="#style/AppTheme">
<activity
android:name=".LoginActivity"
android:clearTaskOnLaunch="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SettingsActivity">
</activity>
<activity
android:name=".GraphActivity">
</activity>
</application>
</manifest>
This is my style:
<resources>
<color name="basic_text">#000000</color>
<color name="basic_text_buttons">#FFFFFF</color>
<color name="blue_bpi">#003676</color>
<color name="light_green_bpi">#D6FFDA</color>
<style
name="AppTheme" parent="#style/Theme.Indupac">
</style>
</resources>

I found a solution for my problem. When I applied the default theme "#style.AppCompat.Light.DarkActionBar" and added "colorPrimary" as an item, then it worked like a charm. Keep in mind not to put "android:" in front of "colorPrimary", because that requires API 21. Here is what i got:
<resources>
<color name="basic_text">#000000</color>
<color name="basic_text_buttons">#FFFFFF</color>
<color name="blue_bpi">#003676</color>
<color name="light_green_bpi">#D6FFDA</color>
<style
name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/blue_bpi</item>
<item name="colorAccent">#color/blue_bpi</item>
</style>
</resources>

Related

How to display Situm (indoor positioning) maps in Android Studio?

Suppose that the Situm API key is already implemented.
I replaced the API key with ## in the code to not show the key for security.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.bkcnavigator" >
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"`enter code here`
android:dataExtractionRules="#xml/data_extraction_rules"
android:fullBackupContent="#xml/backup_rules"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.BKCNavigator"
tools:targetApi="31" >
<activity
android:name=".MainActivity"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Google play services version -->
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<!-- GMaps api key -->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="##" />
<!-- Situm SDK credentials -->
<meta-data
android:name="es.situm.sdk.API_USER"
android:value="dr-montaa#hotmail.com"/>
<meta-data
android:name="es.situm.sdk.API_KEY"
android:value="##"/>
</application>
</manifest>
The Output:
It shows a Google map and a search bar (Not working yet)at the top.
I want the output to be like this:
It shows a google map with the image of the floor of the building.

Hide navigation bar COMPLETELY (Android Studio)

There are many videos about hiding navigation bar by using setSystemUiVisibility or something like this. However, navigation bar is being showed again after using keyboard to write username or password. And probably that solution will be broken because of other things. Help me to hide navigation bar completely like in the games. My app just don't need that.
In your res/values/styles.xml file copy this style:
<style name="AppTheme.NoActionBar" parent="AppTheme">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
Here the parent theme is the theme you are currently using. Typically it will be in the file like this as default:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
Then go to the AndroidManifest.xml and make it like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.package.name">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity
android:theme="Apptheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
What you do here is change your activity's theme to Apptheme.NoActioBar theme.
Then run your app and you will have no action bar.

Mainactivity statusbar color is white, can't change it

I've tried everything and i've not been able to the change the color of the statusbar. I have multiple activities that uses the same Style theme where I have declared the statusbar color as blue and it works. Mainactivity should also be using the same theme but its not. I've also tried changing the color by code which has not given any results.
Android manifest:
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="#drawable/logowbg"
android:label="#string/app_name"
android:roundIcon="#drawable/logowbg"
android:supportsRtl="true"
android:theme="#style/AppTheme.MainActCustom">
<activity android:name=".SplashScreen" android:theme="#style/Apptheme.CustomSplash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ShowNewsDetailed" />
<activity android:name=".MainActivity" />
<activity
android:name=".OptionsPop"
android:theme="#style/Apptheme.CustomPopupStyle" />
<activity android:name=".Settings" />
</application>
MainActCustom:
<style name="AppTheme.MainActCustom" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:background">#color/mainBGColor</item>
<item name="android:statusBarColor">#color/mainBGColor</item>
<item name="android:textColorSecondary">#color/mainTextBGColor</item>
<item name="colorPrimary">#color/mainBGColor</item>
</style>
Check if there ir2 styles files in your project. If there is, one is named "styles (v21)".
Check the line
<item name="android:statusBarColor">#android:color/transparent</item>

Android Studio Not Applying My Design Changes

I'm trying to change the theme of some activities by removing the action bar or changing the title of it. At first i was doing it using the AppTheme option in the design tab. However, after searching online i knew that i was doing it the wrong way, so i proceeded to the AndroidManifest file to do my changes manually. Unfortunately, it's not working either. Here's the code of my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.wonderheart">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"
android:label="Sign Up"/>
<activity
android:name=".Login"
android:label="Log In"/>
<activity android:name=".drawable.welcome">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".UserProfile"
android:theme="#style/AppTheme.NoActionBar"/>
<activity android:name=".HomePage" >
</activity>
</application>
</manifest>
Here are some of my activities that I'm trying to change:
Action Bar Title Changed Successfully
Action Bar Title Didn't Change
I'm using Android Studio 3.0 Preview and Kotlin. I hope you can help because i can't progress on my work without fixing this design issue!
You can fix problem two way.
1. Use common one theme for all activities and use code for hiding and showing action bar in onCreate method
// Set up the toolbar
val toolbar = findViewById(R.id.toolbar) as Toolbar
setSupportActionBar(toolbar)
var actionBar = supportActionBar
//For hiding android actionbar
actionBar.hide();
//For showing android actionbar
//actionBar.show();
Use custom style for activity where you don’t want to show action bar in example below I did it for application level but you can use it your way with your any other activities
style.xml
<resources>
<style name = "AppTheme" parent = "android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name = "NoActionBar" parent = "#android:style/Theme.Holo.Light">
<item name = "android:windowActionBar">false</item>
<item name = "android:windowNoTitle">true</item>
</style>
</resources>
AndroidManifest.xml
<application
android:allowBackup = "true"
android:icon = "#drawable/ic_launcher"
android:label = "#string/app_name"
android:theme = "#style/NoActionBar" <!--This is the important line-->
>
<activity

How to hide toolbar with drawer layout and still be be able to use the open drawer button(three lines)?

I'm new to android and I'm trying to hide toolbar in drawer
layout for a time now but couldn't do it.If I change primary
color to 0 opacity then I get "A TaskDescription's primary
color should be opaque" error I know the reason of the error
so I've to set 255 opacity to primary color as taskDescription
takes primary color. I want the following UI;
[UI1
I've used following theme;
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
Customize your theme here.
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
manifest ;
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/NoActionBar"
android:supportsRtl="true">
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I did manage to transparent the status bar by setting up primaryDark color to opacity 0.
color.xml ;
<?xml version="1.0" encoding="utf-8"?><resources>
<color name="colorPrimary">#3f51b5</color>
<color name="colorPrimaryDark">#00303f9f</color>
<color name="colorAccent">#FF4081</color>
<color name="toolbarcolor">#00ffffff</color>
Use tooolbar.hide() method or instead you can use scrollbars to whole activity with toolbars so that it will give a hide toolbar behaviour
or just give a trasparent color to toolbar
I hope it will help a little bit

Resources