Android app masthead display - android

I have created an app using Android Studio 2.3.3, choosing Empty Activity Template. After its creation I went and changed the background color to something like colorAccent and I also changed the colorPrimary to colorAccent in colors.xml.
Now, when I ran the app, following emulator display appeared.
As you can see, it displays my app name, followed by a dark line.
I don't understand where this dark line has come from and how can I get rid of this?
However, this dark line does not appear in Android Studio design mode (see screenshot below).

it is shadow of action bar my friend
to remove this shadow add below lines to your theme under res/values/style
<style name="MYTheme" parent="android:Theme.Holo.Light">
<item name="colorPrimary">#color/colorWhite</item>
<item name="colorPrimaryDark">#color/colorWhite</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowContentOverlay">#null</item>
<item name="android:windowContentOverlay">#null</item>
</style>
now add this in manifest file this to your activity
<activity
android:name=".YourActivity"
android:theme="#style/MYTheme"/>
or try this
getSupportActionBar().setElevation(0);

Related

how to change color appbar of mapview flutter ?

hello I search change the color of the mapview pluggin for flutter.
Here is the link
https://github.com/apptreesoftware/flutter_google_map_view
If I understand, the plugin call android and ios native code to create the map.
I search on the kotlin code of android but I didn't see any color attribut to change the appbar color. If someone know how to add simple ios android code in the pluggin to change the color it will be perfect. thank you
Go to your styles.xml file at res/values and add the following slyle:
<style name="MapViewTheme" parent="#style/Theme.AppCompat">
<item name="colorPrimary">#008000</item>
</style>
and refer to this style on your manifest, like this:
<activity android:name="com.apptreesoftware.mapview.MapActivity" android:theme="#style/MapViewTheme"/>
On the example above I changed the color to green (#008000). Change this value for your desired color.
You could try setting up a custom theme:
Add to your styles.xml file:
<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>
Replace all #color/color... with your color codes where colorPrimary is the color of your AppBar.
For reference, this sets the theme in AndroidManifest.xml:
<activity android:name="com.apptreesoftware.mapview.MapActivity" android:theme="#style/Theme.AppCompat.Light.DarkActionBar"/>
And here is a documentation about themes.

App Crash at Launch (Material Theme issue)

I'm actually creating an app an I would like to use Material Theme Light.
So I put the line android:theme = "#android:style/Theme.Material.light"
on the manifest and no errors are displayed.
However when launching the app on my phone it crashes at launch although no errors are displayed in my xml/java sources.
I'm sure this line is the cause, because when I change the manifest to #style/AppTheme, it works and lauches.
It's driving me crazy, I need your help please.
It depends on your activity, What does your activity extend from? If it extends from AppCompatActivity you can't set material theme.
you should set AppTheme as your theme android:theme="#style/AppTheme"
and in style file, set AppCompat Theme as your parent:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
Try this it will work click on values in resources than open styles.xml file and change this
with following
i was getting the same issue and it is due to the update in the material lib

UI freezes on removing white screen before splash

I am trying to remove white screen before splash so i followed solutions mentioned in these links
How To fix white screen on app Start up?
White screen before splashscreen
I tried almost every solution mentioned here
which includes changing activity theme to this
android:theme="#android:style/Theme.Translucent.NoTitleBar"
or adding this to my theme
<item name="android:windowDisablePreview">true</item>
but implementing any of this freezes the UI for a while on click of the App icon after that everything works fine as desired.
Has anyone succeeded to fix this lag. Any help will be appreciated.
create a custom theme like,
//splashTheme
//create in styles
<style name="splashTheme" parent="AppTheme">
<!-- Customize your theme here. -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
and then apply the theme as follows,
//manifest file
<activity
android:name=".SplashActivity"
android:theme="#style/AppTheme.splashTheme"
android:windowSoftInputMode="adjustResize|stateHidden" />
try this.
following changes work for me on mac:
1.Goto android studio preferences.
2.In Build,Execution and Deployment select "Instant run".
3.disable-Enable instant run to hot swap code/resource changes on deploy.
4.apply changes,clean project and rebuild again.
Finally got my answer Splash Screen in Right Way. I do just following.
In values-->styles.xml I created splash screen background image
<style name="Splash" parent="AppTheme.NoActionBar">
<item name="android:windowBackground">#drawable/splash</item>
</style>
For below api 19, in values-19->styles.xml I used
<style name="Splash" parent="AppTheme.NoActionBar">
<item name="android:windowBackground">#drawable/splash</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
I removed setContentview() from SplashActivity and added style for splash screen in Manifest.xml file android:theme="#style/Splash"

How to style Android's AppBar action text?

I need to change text size of action buttons in AppBar/Toolbar. It should be 14sp, but I'll use 20sp in this example, because it is more evident. I am using appcompat-v7 22.1.1
At first I tried to use theme attribute android:actionButtonStyle:
<style name="FirstAttemptTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionButtonStyle">#style/Custom.Widget.AppCompat.Light.ActionButton</item>
</style>
<style name="Custom.Widget.AppCompat.Light.ActionButton" parent="Widget.AppCompat.Light.ActionButton">
<item name="android:textSize">20sp</item>
</style>
Then I ran application on the Lollipop and the result was as needed:
But then I used an emulator with lower version and my theming had no effect:
I digged a little deeper and discovered that abc_action_menu_item_layout.xml is used for action menu items and it has a line android:textAppearance="?attr/actionMenuTextAppearance"
So I tried to modify this theme attribute (I also had to add textStyle:bold):
<style name="SecondAttemptTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionMenuTextAppearance">#style/Custom.TextAppearance.AppCompat.Widget.ActionBar.Menu</item>
</style>
<style name="Custom.TextAppearance.AppCompat.Widget.ActionBar.Menu" parent="TextAppearance.AppCompat.Widget.ActionBar.Menu">
<item name="android:textSize">20sp</item>
<item name="android:textStyle">bold</item>
</style>
As in the first time, the result was as needed on Lollipop and no effect on any version below.
So, the question is: how to properly change text size for action menu item?
PS: I created a simple project on github to demostrate my issue
It appears that actionButtonStyle and actionMenuTextAppearance should be used without android: namespace.
As it can be seen in values-v21/values.xml of support library, Lollipop uses attribute from system theme (note the android: prefix), that's why my attempts worked with it:
<style name="Base.V21.Theme.AppCompat.Light" parent="Base.V7.Theme.AppCompat.Light">
...
<item name="actionButtonStyle">?android:attr/actionButtonStyle</item>
...
</style>

Android 4 ActionBar - changing textColor when using Action Bar Sherlock

I am using the ActionBarSherlock and almost everything seems to work fine.
But I want the title text color in white. When using the Sherlock-Actionbar it works fine but not with the original ActionBar in Android 4
In an act of desperation I tried this:
<style name="Widget.AppTheme.ActionBar" parent="Widget.Sherlock.Light.ActionBar">
<item name="titleTextStyle">#style/TextAppearance.AppTheme.Widget.ActionBar.Title</item>
<item name="android:gravity">center</item>
<item name="android:background">#color/white</item>
<item name="android:textColor">#color/white</item>
</style>
and found that the background changed as told to white. So this is obviously the right place to change. But still changing the textColor to white doesn't work for me.
I'm using this as my Theme:
<style name="AppTheme" parent="Theme.Sherlock.Light">
<item name="android:actionBarStyle">#style/Widget.AppTheme.ActionBar</item>
<item name="actionBarStyle">#style/Widget.AppTheme.ActionBar</item>
<item name="textColorPrimary">#color/white</item>
<item name="android:textColor">#color/white</item>
...
</style>
So any idea what could be the problem? Why is it working with the background but not with the textColor?
Thanks,
Tobias
--- EDIT FROM HERE ---
I just found out that if I use my theme programmaticall like
setTheme(R.style.Widget_AppTheme_ActionBar);
It works. But if I rely on the settings I have in my Manifest it doesn't.
<application ... android:theme="#style/AppTheme" >
but
<application ... android:theme="#style/Widget_AppTheme_ActionBar" >
would do fine - even though the other styles from the AppTheme wouldn't be set.
So it looks like using a theme that defines an own ActionBarStyle doesn't work.
Has anyone any idea?
Okay, sorry for answering my own question. I eventually realized my problem.
Of cause I have to use these two arguments
<item name="titleTextStyle">#style/TextAppearance.AppTheme.Widget.ActionBar.Title</item>
<item name="android:titleTextStyle">#style/TextAppearance.AppTheme.Widget.ActionBar.Title</item>
Since the first one is working for Android 2.x with the ActionBarSherlock and the second one is doing the same for the native Action Bar.
I hope this helps someone who has the same trouble as I had.

Categories

Resources