Remove shadows below actionbar appcompat - java

Is it possible to remove the shadow below the Actionbar?
I am using the AppCompat v7 library.

This works with AppCompat:
<style name="MyAppTheme" parent="Theme.AppCompat.Light">
<item name="actionBarStyle">#style/MyActionBarTheme</item>
</style>
<style name="MyActionBarTheme" parent="Base.Widget.AppCompat.Light.ActionBar.Solid">
<item name="elevation">0dp</item>
</style>

Add this in style.xml :
<style name="MyTheme" parent="Theme.Sherlock">
....
<item name="windowContentOverlay">#null</item>
<item name="android:windowContentOverlay">#null</item>
....

Related

When changing ActionBarSize, leaves an small margin to layout below

I am using the code below for changing actionbar size.
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:textAllCaps">false</item>
<item name="android:windowFullscreen">true</item>
<item name="actionBarSize">26.0dip</item>
</style>
Here is my result
Image
Why this margin exists on child?

AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant)

iOS developer here thrown to the wolves of an Android project. I am getting a few error codes that all say something similar to ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant). as soon as the following code snippet runs:
view = inflater.inflate(R.layout.f_basic_dashboard_screen, null, false)
My inflater is instantiated as follows:
val inflater: LayoutInflater = LayoutInflater.from(SqueaksApplication.getApplicationInstance())
SqueaksApplication.getApplicationInstance() just returns an instance of public class SqueaksApplication extends Application
Almost every answer I have found to this question points to the project's manifest as the issue and needing to provide a theme for the project. My project's manifest looks like the following:
<application
android:name=".SqueaksApplication"
android:allowBackup="false"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning,UnusedAttribute"
tools:replace="android:icon,android:allowBackup">
As you can see my manifest already includes the line android:theme="#style/AppTheme"
My project uses the layout inflator in many different places, but this is the only one I have come across that is throwing errors. Would appreciate any insight, or solutions you may have, thanks!
Edit: As requested this is my styles.xml:
<style name="MainActivityTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:actionMenuTextColor">#FFF</item>
<item name="actionBarStyle">#style/MainActivityTheme.Toolbar</item>
<item name="actionBarTheme">#style/MainActivityTheme.ToolbarOverlay</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="toolbarStyle">#style/MainActivityTheme.Toolbar</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:textColorPrimary">#color/text_primary</item>
<item name="android:textColorSecondary">#color/text_secondary</item>
<item name="android:windowBackground">#color/background</item>
<item name="actionOverflowButtonStyle">#style/MainActivityTheme.ActionOverflow</item>
<item name="alertDialogTheme">#style/AlertDialogTheme</item>
</style>
<style name="AlertDialogTheme" parent="Base.Theme.AppCompat.Light.Dialog.Alert">
<item name="android:textColorPrimary">#DE000000</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="MainActivityTheme.ActionOverflow" parent="Base.Widget.AppCompat.ActionButton.Overflow">
<item name="android:src">#drawable/ic_settings</item>
</style>
<style name="MainActivityTheme.Toolbar" parent="Widget.AppCompat.ActionBar.Solid">
<item name="background">#color/colorPrimary</item>
<item name="elevation">4dp</item>
<item name="titleTextAppearance">#style/MainActivityTheme.ToolbarTextAppearance</item>
<item name="android:textColorPrimary">#android:color/white</item>
<item name="android:textColorSecondary">#android:color/white</item>
</style>
<style name="MainActivityTheme.ToolbarOverlay" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="android:textColorPrimary">#android:color/white</item>
<item name="android:textColorSecondary">#android:color/white</item>
</style>
<style name="MainActivityTheme.ToolbarTextAppearance" parent="TextAppearance.AppCompat.Title">
<item name="android:textColor">#81be41</item>
<item name="android:textSize">16sp</item>
<item name="android:textStyle">bold</item>
</style>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:actionMenuTextColor">#FFF</item>
<item name="actionBarStyle">#style/Toolbar</item>
<item name="actionBarTheme">#style/ToolbarOverlay</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="toolbarStyle">#style/Toolbar</item>
<item name="android:textColorPrimary">#color/text_primary</item>
<item name="android:textColorSecondary">#color/text_secondary</item>
<item name="android:windowBackground">#color/background</item>
<item name="actionOverflowButtonStyle">#style/ActionOverflow</item>
<item name="alertDialogTheme">#style/AlertDialogTheme</item>
</style>
<style name="AppTheme.Dark" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:windowBackground">#color/colorPrimary</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="ActionOverflow" parent="Base.Widget.AppCompat.ActionButton.Overflow">
<item name="android:src">#drawable/ic_dots_vertical_white</item>
</style>
<style name="Toolbar" parent="Widget.AppCompat.ActionBar.Solid">
<item name="background">#color/colorPrimary</item>
<item name="elevation">4dp</item>
<item name="titleTextAppearance">#style/ToolbarTextAppearance</item>
<item name="android:textColorPrimary">#android:color/white</item>
<item name="android:textColorSecondary">#android:color/white</item>
</style>
<style name="ToolbarOverlay" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="android:textColorPrimary">#android:color/white</item>
<item name="android:textColorSecondary">#android:color/white</item>
</style>
<style name="ToolbarTextAppearance" parent="TextAppearance.AppCompat.Title">
<item name="android:textColor">#81be41</item>
<item name="android:textSize">20sp</item>
</style>
<style name="Splash" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">#drawable/background_splash</item>
</style>
<style name="squeak_item_popup_menu_animation">
<item name="android:windowEnterAnimation">#anim/squeak_item_popup_menu_animation_enter</item>
<item name="android:windowExitAnimation">#anim/squeak_item_popup_menu_animation_exit</item>
</style>
<style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
Your issue is the context used: val inflater: LayoutInflater = LayoutInflater.from(SqueaksApplication.getApplicationInstance()).
The ApplicationContext doesn't have your app theme.
You need to pass the Activity, not an Application Context.

DatePickerDialog buttons not showing the label

The two buttons at the bottom will not show the labels. This is how I am instantiating the date picker new DatePickerDialog(classname.this, date, myCalendar
.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
myCalendar.get(Calendar.DAY_OF_MONTH)).show();
I am running Android Studio 3.2 Canary and target sdk of 28.
You can use this to apply material button style :
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:buttonBarPositiveButtonStyle">#style/Widget.MaterialComponents.Button</item>
<item name="android:buttonBarNegativeButtonStyle">#style/Widget.MaterialComponents.Button.TextButton</item>
<item name="android:buttonBarNeutralButtonStyle">#style/Widget.MaterialComponents.Button</item>
</style>
Result : materialDatePicker
Check for <item name="colorAccent">#color/colorAccent</item> in your styles.xml, button text color will be same as value of colorAccent in colors.xml.
Edit:-
Update your style as following, It will work:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:buttonBarPositiveButtonStyle">#style/DialogButtonStyled</item>
<item name="android:buttonBarNegativeButtonStyle">#style/DialogButtonStyled</item>
<item name="android:buttonBarNeutralButtonStyle">#style/DialogButtonStyled</item>
</style>
<style name="DialogButtonStyled" parent="Theme.MaterialComponents.Light">
<item name="android:textColor">#color/colorWhite</item>
</style>

Cannot Change Action Bar Text Color

I have read several threads on this topic and have implemented the below code. However, I cannot change change the text color of my Action Bar text:
<style name="AppTheme.NoActionBar">
<item name="android:statusBarColor">#android:color/white</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:textColor">#color/white</item>
<item name="android:actionBarStyle">#style/MyTheme.ActionBarStyle</item>
</style>
<style name="MyTheme.ActionBarStyle" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
</style>
<style name="AppThemeLight" parent="Theme.AppCompat.Light.DarkActionBar">
...
<item name="android:textColorPrimary">#color/yourColor</item>
</style>
I use Toolbar and this works for me. Too bad i couldn't repeat it with inheritance.

Action bar not showing text and icons on pre Lollipop devices

So my app is almost done. I have Xperia Z1 which runs Android Lollipop and everything looks fine on it.
Today I sent APK file to my friend who have Xperia T which runs on Android 4.3
He said that everything runs perfect, except actionbar is not showing text or icons. It shows text and icons only on activities that have ListViews.
I don't even know what code to past here.. So if anyone could help I would be thankfull. And please write down what code do you want me to copy.
This is how activites look like:
public class BlaBlaBla extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_programi_specijalizacija_ruke);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
and styles
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="elevation">0dp</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="NavigationDrawerStyle">
<item name="android:textSize">14sp</item><!-- text size in menu-->
<item name="android:background">#f2f2f2</item>
<item name="android:listPreferredItemHeightSmall">36dp</item><!-- item size in menu-->
</style>
<style name="AppTheme.BrandedLaunch" parent="AppTheme">
<item name="android:windowBackground">#drawable/branded_logo</item>
</style>
<style name="Theme.MyApp.ActionBar" parent="style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="elevation">0dp</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="elevation">0dp</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">
<item name="elevation">0dp</item>
<item name="android:windowContentOverlay">#null</item>
/>
</style>
<style name="FullscreenTheme" parent="AppTheme">
<item name="android:actionBarStyle">#style/FullscreenActionBarStyle</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">#null</item>
<item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
<item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
</style>
<style name="FullscreenActionBarStyle" parent="Widget.AppCompat.ActionBar">
<item name="android:background">#color/black_overlay</item>
</style>
</resources>
styles v21
<resources>>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:elevation">0dp</item>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="elevation">0dp</item>
<item name="android:windowContentOverlay">#null</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:navigationBarColor">#color/black</item>
</style>
</resources>
styles v19
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="elevation">0dp</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="NavigationDrawerStyle">
<item name="android:textSize">14sp</item><!-- text size in menu-->
<item name="android:background">#f2f2f2</item>
<item name="android:listPreferredItemHeightSmall">36dp</item><!-- item size in menu-->
</style>
<style name="AppTheme.BrandedLaunch" parent="AppTheme">
<item name="android:windowBackground">#drawable/branded_logo</item>
</style>
<style name="Theme.MyApp.ActionBar" parent="style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="elevation">0dp</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="elevation">0dp</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">
<item name="elevation">0dp</item>
<item name="android:windowContentOverlay">#null</item>
/>
</style>
<style name="FullscreenTheme" parent="AppTheme">
<item name="android:actionBarStyle">#style/FullscreenActionBarStyle</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">#null</item>
<item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
<item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
</style>
<style name="FullscreenActionBarStyle" parent="Widget.AppCompat.ActionBar">
<item name="android:background">#color/black_overlay</item>
</style>
</resources>
And in AndroidManifest all activities have this:
android:theme="#style/ThemeOverlay.AppCompat.ActionBar" />

Categories

Resources