I keep seeing my domain name in the ToolBar in the past I would just use the Manifest file with this line android:label="#string/app_name" I can accomplish this in the ActivityMain.java with title. but would prefer to use the xml and strings concept. The only thing I have done different is create a custom style in the styles.xml for some TextView widgets tools v 24.0.2 V7 24.2.0 code posted
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- 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="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Light"/>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>-->
<style name="MyStyle" parent="AppTheme">
<item name="android:textColor">#f10909</item>
<item name="android:textSize">20sp</item>
<item name="android:width">190dp</item>
</style>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.XXX.newstyletest">
<application>
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:title="what the Hell"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity" android:theme="#style/MyStyle">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
Is this an issue because of the custom style of has something changed ?
or what the heck am I doing wrong
You're going to scream when you SEE what is wrong if you look real close at you AndroidManifest.xml file you will see you have a situation where the code below the is UNREACHABLE because you have a closing brace behind the word application So just remove that > and life will be good
Related
I'm trying to get rid of the ActionBar in an android app.
here's the manifest
<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="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
and here's the styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" 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>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
</resources>
I did change the AppTheme style to NoActionBar, but the emulator still shows the action bar, What am I missing ?
it's because you are setting wrong theme for your app,AppTheme parent should remove action bar
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="AppThemeNoActionBar">
<!-- 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="AppThemeNoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>
Remove android:theme="#style/AppTheme.NoActionBar from MainActivity entry in the manifest and then run your app.
stupidly enough, I didn't take a look at the main activity xml, which included an AppBarLayout widget, so I removed it and rearranged the layout, and now no action bar appears
Can someone please help me understand how to add a background color to my bottom navigation view. I have tried a multitude of things online. If I specify individual colors for each of background, itemBackground, itemIconTint etc. then it shows in the AS preview but doesn't reflect on the device when I launch the app. [The device has Android 8.0.0 on it].
If I use the style attribute then the BottomNavigationView vanishes from the AS preview and there is no difference in the application when I run it. I was successfully able to apply ripple effects to the icon clicks but this seems to completely stump me. And as per Android styles this should have worked. [https://developer.android.com/guide/topics/ui/look-and-feel/themes#Theme]
Code in styles.xml
<resources>
<!-- 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="AppTheme.NoActionBars">
<item name="windowActionBar">true</item>
<item name="windowNoTitle">true</item>
<!-- 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="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="BottomNavigation" parent="AppTheme">
<item name="android:background">#color/colorAccent</item>
<item name="itemBackground">#drawable/bottom_navigation_colors</item>
<item name="itemIconTint">#drawable/navigation_bar_txt_color</item>
<item name="itemTextColor">#drawable/navigation_bar_txt_color</item>
</style>
</resources>
My Manifest has the following
<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=".screens.MainActivity"
android:label="#string/title_activity_main"
android:theme="#style/AppTheme.NoActionBars">
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.MAIN" />-->
<!--<category android:name="android.intent.category.LAUNCHER" />-->
<!--</intent-filter>-->
</activity>
<activity android:name=".screens.LoginActivity"
android:label="LoginActivity"
android:theme="#style/AppTheme.NoActionBars">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I tried using navigation.setBackgroundColor() from the Java code and it worked for me.
But I still cannot get it to work using XML and styles. So will mark this as the answer for now, until a better answer explains why XML style isn't working.
Here is my AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.domain.project"
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="25"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name="com.tns.NativeScriptApplication"
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name="com.tns.NativeScriptActivity"
android:label="#string/title_activity_kimera"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#style/LaunchScreenTheme">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="#style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"/>
</application>
</manifest>
And here is my values/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- theme to use FOR launch screen-->
<style name="LaunchScreenThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
<!--<item name="toolbarStyle">#style/NativeScriptToolbarStyle</item>-->
<item name="colorPrimary">#color/ns_primary</item>
<item name="colorPrimaryDark">#color/ns_primaryDark</item>
<item name="colorAccent">#color/ns_accent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowBackground">#drawable/splash_screen</item>
<item name="android:windowActionBarOverlay">false</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
<style name="LaunchScreenTheme" parent="LaunchScreenThemeBase">
</style>
<!-- theme to use AFTER launch screen is loaded-->
<style name="AppThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
<!--<item name="toolbarStyle">#style/NativeScriptToolbarStyle</item>-->
<item name="colorPrimary">#color/ns_primary</item>
<item name="colorPrimaryDark">#color/ns_primaryDark</item>
<item name="colorAccent">#color/ns_accent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="AppTheme" parent="AppThemeBase">
</style>
<!-- theme for actioon-bar
<style name="NativeScriptToolbarStyleBase" parent="Widget.AppCompat.Toolbar">
<item name="android:background">#color/ns_primary</item>
<item name="theme">#style/ThemeOverlay.AppCompat.ActionBar</item>
<item name="popupTheme">#style/ThemeOverlay.AppCompat</item>
</style>
<style name="NativeScriptToolbarStyle" parent="NativeScriptToolbarStyleBase">
</style> -->
</resources>
I can change values in android:windowFullscreen and the app goes fullscreen or not, accordingly to the boolean set. So, I know that the manifest file is being parsed correctly. However, the title bar / action bar / toolbar is simply never hiding and always appears with the app in the title.
I am using this angular seed, not sure if relevant: https://github.com/TeamMaestro/angular-native-seed
I've been stuck in this for some time now, can someone help? Thanks :)
I can change values in android:windowFullscreen and the app goes
fullscreen or not, accordingly to the boolean set. So, I know that the
manifest file is being parsed correctly. However, the title bar /
action bar / toolbar is simply never hiding and always appears with
the app in the title.
Your manifest is correct, but your preview is set up wrong. You have to remember that the Android Studio preview doesn't reflect how your application will actually look when run on a real device.
I created a dummy project to explain. Here is code that removes the action bar, similar to what you have:
android:theme="#style/Theme.AppCompat.Light.NoActionBar">
Which looks like this in source code:
<style name="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Now this clearly tells the app to not show an action bar, just like your theme does. However, if you look at the preview, you will see this:
So then how do you make your preview accurately reflect your theme? Well, click here:
And adjust your theme to include no action bar!
As a result, you have no action bar in the preview and in the application:
Let me know if this was helpful!
i Go Through Your Code and havent found any Problem ,But Maybe There is issue with code but U can Try Compare with This style that works for me:
<resources>
<!-- 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="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Add this code to style.xml
<style name="AppTheme.NoActionBar.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
and add this code to AndroidManifest.xml
<activity
android:name="com.tns.NativeScriptActivity"
android:label="#string/title_activity_kimera"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#style/AppTheme.NoActionBar.NoActionBar">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="#style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"
android:theme="#style/AppTheme.NoActionBar.NoActionBar"/>
Try this in your styles.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<!-- Customize your theme here. -->
I am trying out the material design. I created a theme MyMaterialTheme in the styles.
Styles:
<resources>
<!-- Theme for the material design of the app -->
<style name="MyMaterialTheme" parent="MyMaterialTheme.Base"></style>
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#color/colorPrimaryApp</item>
<item name="colorPrimaryDark">#color/colorPrimaryDarkApp</item>
<item name="colorAccent">#color/colorAccentApp</item>
</style>
<!-- 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="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
In my AndroidManifest.xml, I included this theme (MyMaterialTheme). I can confirm that my theme is applied as it has taken the correct colors from it. I had assigned windowActionBar as false and windowNoTitle as true, but still I am seeing the ActionBar and the title when I run the app. Could anyone point out where I am going wrong?
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/MyMaterialTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<!-- android:theme="#style/AppTheme.NoActionBar"> -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Here is the screenshot of the emulator:
Check your activity_main.xml file. Android Studio's default layouts will typically have a toolbar manually added to each layout, even if your app theme says there is none.
your base style that your material style extend it should be noTitlebar like this code
parent="Theme.AppCompat.Light.NoActionBar"
I have following style definitions in my res/values/style.xml file:
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:textColor">#fff</item>
<item name="android:textSize">12sp</item>
</style>
<style name="MainActivity" parent="AppTheme">
<item name="android:textColor">#f0f</item>
<item name="android:background">#color/black</item>
</style>
And following code in manifest file:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:theme="#style/MainActivity"
android:name="com.example.mygateway.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 expect that textColor #f0f will be applied to MainActivity activity, but it isn't.
Neither textColor no other items i tried are applied.
Actually the only AppTheme is applied to the activity and the whole application.
I'am a beginner in android development. What I do wrong?
Please help.
Thanks!
As official docs state:
"If you want to inherit from styles that you've defined yourself, you do not have to use the parent attribute. Instead, just prefix the name of the style you want to inherit to the name of your new style, separated by a period. For example, to create a new style that inherits the CodeFont style defined above, but make the color red, you can author the new style like this:"
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:textColor">#fff</item>
<item name="android:textSize">12sp</item>
</style>
<style name="AppTheme.MainActivity">
<item name="android:textColor">#f0f</item>
<item name="android:background">#color/black</item>
</style>
and
<activity android:theme="#style/AppTheme.MainActivity"
...>
...
</activity>`