Android Studio Not Applying My Design Changes - android-studio

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

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.

App Bar is not showing in Android Studio but showing on an actual android device

I have already checked similar problems like mine but none of it helped. I also checked my previous project with the same AppTheme, they are the same but I have noticed everytime I create a new android project, the App bar is not showing even after several "Rebuild Project".
This is what my styles.xml shows
<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>
</resources>
This is what my AndroidManifest.xml shows
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mycontact">
<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">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
My MainActivity.java (Haven't put code yet)
package com.example.mycontact;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
And my activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
</LinearLayout>
I have also tried changing the layout from ContraintLayout, RelativeLayout but nothing has changed. Zooming in and zooming out the layout doesn't change at all. Here is a snapchat.. Thank you for your help.
activity_main.xml page
Your styles.xml and other files seem to be in order, so try the following out.
Click the "Eye" icon on the toolbar above the XML Layout Preview, and then select "Show Layout Decorations" if it is unchecked. This should make it display both the AppBar and the system navigation bar.
Screenshots for reference, taken on Android Studio 3.3:
1. Layout with decorations missing
2. Press the 'Eye' icon, and select the option
3. The decorations (AppBar and system navigation bar) should now be visible

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 custom theme won't apply

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>

Resources