Android CollapsingToolbarLayout Title padding while collapsed - java

I'm trying to use app:collapsedTitleTextAppearance for my title while collaping toolbar layout is collapsed and showing toolbar only.
this is my problem:
I have used app:collapsedTitleTextAppearance and this is the style:
<style name="about_title">
<item name="android:paddingRight">100dp</item>
<item name="android:layout_marginRight">10dp</item>
</style>
How can I fix this?

Related

ActionMode with same theme as Toolbar in Android

In Android, is there any way to give an ActionMode the same appearance as the normal Toolbar? Currently my ActionMode looks different to the Toolbar in that the background is slightly brighter (at least using Theme.AppCompat.NoActionBar), the MenuItems are fully black/white (depending on the theme) instead of colorControlNormal (which I set them to) and most annoyingly, there is an underline under the ActionMode that I can't seem to get rid of. Instead, I'm trying to make the ActionMode indistinguishable from the Toolbar.
The Toolbar (also what the ActionMode is meant to look like):
What the ActionMode currently looks like:
Any help would be highly appreciated!
For changing the background color of ActionMode & Remove the bottom line. You can use actionModeStyle where you can set background to your desired color.
For changing the icon color you can set colorControlNormal inside the actionBarTheme.
So your theme would look like this:
<style name="Theme.AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<!--add this-->
<item name="actionModeStyle">#style/ActionModeStyle</item>
<item name="actionBarTheme">#style/MyActionBarTheme</item>
</style>
<style name="MyActionBarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
//replace with your own desired color
<item name="colorControlNormal">#a00</item>
</style>
<style name="ActionModeStyle" parent="#style/Widget.AppCompat.ActionMode">
//replace with your own desired color
<item name="background">#color/colorPrimary</item>
<item name="titleTextStyle">#style/ActionModeTitleTextStyle</item>
</style>
<style name="ActionModeTitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionMode.Title">
//replace with your own desired color
<item name="android:textColor">#a00</item>
</style>

Android AppCompat ActionBar - Left Align Logo

Within the ActionBar, I am trying to left align the logo and also display the Activity title. I'm finding it difficult to left align the logo.... and also display the logo and the title together.
My Activity is extending AppCompatActivity. I am using the styles.xml to provide the theme to the app. In the styles.xml theme, I have the following:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">#style/ActionBarLogoTheme</item>
</style>
Which calls the following:
<style name="ActionBarLogoTheme" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="logo">#drawable/logo</item>
<item name="displayOptions">useLogo|showHome|showTitle</item>>
<item name="android:layout_gravity">left</item>
<item name="android:gravity">left</item>
</style>
In the above, the 'gravity' and 'layout_gravity' don't seem to take affect, and also the 'showTitle' display option doesn't seem to take affect also. Would anyone be able to help. The following illustrates what it currently looks like, and what I would like it to look like.
Thank you all.
If you want to use an ActionBar you can use:
<style name="ActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="displayOptions">showHome|useLogo|showTitle</item>
<item name="logo">#drawable/....</item>
</style>
You can also it programmatically:
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayUseLogoEnabled(true);
getSupportActionBar().setLogo(R.drawable....);
getSupportActionBar().setTitle("Title");
But you can also use a Toolbar:
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setNavigationIcon(R.drawable.ic_menu_camera);
setSupportActionBar(toolbar);

How to remove extra white background in buttons after using AppCompat Theme?

TL;DR;
How to remove the below unwanted white area?
I tried to change my theme which extends "Theme.AppCompat.Light.NoActionBar" and added my own customization.
After using the theme, all "pop-up" buttons have an extra white background like above screenshot:
How to remove those extra white area?
What xml attributes are controlling this?
styles.xml
<style name="MyCustomTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/accent</item>
<item name="android:textColorSecondary">#color/secondary_text</item>
<item name="android:alertDialogTheme">#style/CustomAppCompatAlertDialogStyle</item>
<item name="android:actionBarStyle">#style/CustomActionBarStyle</item>
</style>

Android 6 Marshmallow troubles with Spinner on Toolbar

I simply added a spinner with the Toolbar and working fine in all devices of Android up to Android version 5. However when I tested this thing with recently launched Android 6 it's not displaying items in spinner, just blank white background.
What changes I need to make out to resolve this abrupt behaviour. Here below is styles used for this spinner in Toolbar.
style v21 :--
<style name="Widget.MyApp.Toolbar.Spinner" parent="Widget.MyApp.HeaderBar.Spinner">
<item name="android:dropDownSelector">?android:selectableItemBackground</item>
<item name="android:divider">#null</item>
<item name="android:overlapAnchor">true</item>
<item name="android:gravity">left</item>
<item name="android:background">#drawable/toolbar_language_bg</item>
<item name="android:popupBackground">#color/text_color_white</item>
</style>
style:-
<style name="Widget.MyApp.Toolbar.Spinner" parent="Widget.MyApp.HeaderBar.Spinner">
<item name="android:dropDownSelector">?android:selectableItemBackground</item>
<item name="android:divider">#null</item>
<item name="android:gravity">left</item>
<item name="android:background">#drawable/toolbar_language_bg</item>
<item name="android:popupBackground">#color/text_color_white</item>
</style>

Action bar transparency

I'm having trouble with android app.
I try to make my action bar transparent (like google maps or google play music) but instead of becoming transparent it becomes white.
Here is my custom theme:
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:windowActionBarOverlay">true</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
<item name="android:background">#android:color/transparent</item>
<item name="android:logo">#android:color/transparent</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#FFFFFF</item>
</style>
Has anyone got any ideas why is that happening ?
EDIT 1:
I forgot to mention that I'm using fragments. So I have only one activity with Navigation Drawer and a fragment inside. The fragment itself contains a listview.
Thank you all in advance !
You can try the answer in this thread: Transparent Actionbar: custom tabcolor
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
ActionBar actionBar = getActionBar();
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#330000ff")));
actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#550000ff")));
The one changes the color of the ActionBar and the other the color of the tabs attached to it.
If you want to make it completely transperant then your first number of the color should be 00: #00123456, because the colors are in the (Alpha, Red, Green, Blue) schema.

Categories