I am trying to set cursor/hint/icon color of my SearchView in white. Defined the style for it but SearchView is not updating it is showing in black. Kindly suggest what is missing in my code.
styles.xml
<style name="SearchViewStyle" parent="Widget.AppCompat.SearchView.ActionBar" >
<item name="android:textColorPrimary">#color/color_white</item>
<item name="android:textColorHint">#color/color_white</item>
<item name="android:tint">#color/color_white</item>
<item name="queryHint">#string/search_hint</item>
</style>
colors.xml
<color name="color_white">#FFFFFF</color>
SearchView defined in a layout:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary">
<-- other views code -->
<SearchView
style="#style/SearchViewStyle"
android:id="#+id/header_search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="#string/app_name"
android:layoutDirection="rtl"
android:iconifiedByDefault="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:scaleType="centerInside"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
UI on phone screen:
Use androidx.appcompat.widget.SearchView and not SearchView.
SearchView doesn't know what "Widget.AppCompat.SearchView.ActionBar" means.
Related
I want to make the same toolbar. Everything is perfect but can not get the shadow as the picture shows. I design the whole things but can not get the shadow. Can anyone plz guide me. I m posting my code below and attaching the image below:
layout design image
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.cardview.widget.CardView
android:id="#+id/cvToolbar"
style="#style/materialCardView"
android:layout_width="match_parent"
android:layout_height="#dimen/dp_56"
android:layout_marginStart="#dimen/dp_8"
android:layout_marginTop="#dimen/dp_8"
android:layout_marginEnd="#dimen/dp_8"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/ivToolbarBack"
android:layout_width="#dimen/dp_0"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/dp_23"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_arrow_back" />
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/tvToolbarTitle"
style="#style/pinVerificationToolbarTextStyle"
android:layout_width="#dimen/dp_0"
android:layout_height="#dimen/dp_40"
android:layout_marginStart="#dimen/dp_24"
android:layout_marginTop="#dimen/dp_11"
android:layout_marginEnd="#dimen/dp_8"
android:layout_marginBottom="#dimen/dp_5"
android:gravity="top"
android:text="#string/pos_system"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/ivToolbarBack"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
<style name="pinVerificationToolbarTextStyle">
<item name="android:textAppearance">#style/TextAppearance.Text.Regular</item>
<item name="android:textColor">#color/colorBlack</item>
<item name="android:textSize">22sp</item>
<item name="android:letterSpacing">-0.01</item>
<item name="android:textStyle">bold</item>
<item name="fontFamily">#font/martel_sans</item>
</style>
<style name="materialCardView">
<item name="cardBackgroundColor">#color/colorWhite</item>
<item name="cardCornerRadius">26dp</item>
<item name="cardElevation">1dp</item>
<item name="elevation">1dp</item>
<item name="android:translationZ">3dp</item>
</style>
can somebody please help me to resolve.
you can use android:background="#android:drawable/dialog_holo_light_frame" to get shadow also you can make a background drawable using any drawing software like photoshop ,xd etc
you can see this as a reference Android View shadow
Just add android:elevation=“6dp” in your toolbar
In your onCreate method of your activity code add the following code:
kotlin code:
supportActionBar?.elevation = 8F
java code:
getSupportActionBar().setElevation(8);
------------------------OR-----------------
kotlin code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
actionBar?.elevation = 8F
}
java code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getActionBar().setElevation(8);
}
to achieve 8dp of elevation in your app bar. (adding elevation is going to add shadow)
You can change the numeric value to achieve the desired elevation(shadow)
As the title says I nedd an activity with black transparent background and a SearchView on top of it with white background and gray/custom text/icon colors.
This is what I have so far:
activity_search_input.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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=".SearchInput">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/constraintLayout"
android:layout_width="58dp"
android:layout_height="60dp"
android:background="#FFFFFF"
app:layout_constraintEnd_toStartOf="#+id/searchInput"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_back" />
</androidx.constraintlayout.widget.ConstraintLayout>
<SearchView
android:id="#+id/searchInput"
android:layout_width="0dp"
android:layout_height="60dp"
android:background="#FFFFFF"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/constraintLayout"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Even though the background is set to #FFFFFF it is gray!
in manifest:
<activity
android:name=".SearchInput"
android:theme="#style/Theme.AppCompat.Translucent">
</activity>
in styles.xml:
<style name="Theme.AppCompat.Translucent" parent="Theme.AppCompat.NoActionBar">
<item name="android:background">#66000000</item> <!-- Or any transparency or color you need -->
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">#android:style/Animation</item>
</style>
How can I do that? I'm already searching since couple hours for a solution for such a minor thing! Android is absolutely horrendous!
True testing this out was indeed a horrendous experience unless there's an easy method I'm unaware of. Here's a workaround I found for your case.
The main issue is this line <item name="android:background">#66000000</item> in your Translucent style, that messes up the colors which the searchView uses behind the scenes. Remove that and the background you set for searchView should be working now.
But you'll notice all the icons and textcolor remain white you will have to either individually set these with custom icons (for some reason the textColor still wouldn't change) or simply use parent="Theme.AppCompat.Light.NoActionBar" as the parent for your translucent theme.
So now your custom Translucent theme should look like below:
<style name="Theme.AppCompat.Translucent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">#android:style/Animation</item>
</style>
Now since you have removed the window background from theme you will need to set a background to the root layout using android:background="#66000000"
So your activity_search_input.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:background="#66000000"
tools:context=".SearchInput">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/constraintLayout"
android:layout_width="58dp"
android:layout_height="60dp"
android:background="#FFFFFF"
app:layout_constraintEnd_toStartOf="#+id/searchInput"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_back" />
</androidx.constraintlayout.widget.ConstraintLayout>
<SearchView
android:id="#+id/searchInput"
android:layout_width="0dp"
android:layout_height="60dp"
android:background="#FFFFFF"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/constraintLayout"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
The result was this
Tried different ways but this felt the easiest, check if this helps you out, or maybe someone will come up with a better method.
I'm trying to add a BottomAppBar to my activity but there's a error : " java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mathmech.cards/com.mathmech.cards.activity.MainActivity}: android.view.InflateException: Binary XML file line #24: Binary XML file line #24: Error inflating class com.google.android.material.bottomappbar.BottomAppBar"
I tried to follow guides on web but nothing helped
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context=".activity.MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/listView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/bottom_app_bar"
app:fabAlignmentMode="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/colorPrimary"
android:gravity="bottom" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab"
app:layout_anchor="#id/bottom_app_bar"
android:layout_width="wrap_content"
android:src="#drawable/ic_add_black_24dp"
android:layout_height="wrap_content" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
EDIT: added 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>
</resources>
Instead of using your parent theme as Theme.AppCompat.Light.DarkActionBar, use Theme.MaterialComponents or its descendant.
Try with this style in your Bottom App Bar XML.
style=”#style/Widget.MaterialComponents.BottomAppBar”
Yes, changing Theme.AppCompact.Light.DarkActionBar to Theme.MaterialComponents will help your see the xml in layout editor.
Also, you can follow this article
Implementing BottomAppBar I: Material Components for Android
In our previous holo designed app (targetSdkVersion 21, with theme Theme.Sherlock.Light.DarkActionBar), we are using system style attribute attr/actionButtonStyle to define our custom action bar button style.
actionbar_custom_view_done_discard.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<include layout="#layout/actionbar_discard_button" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:background="?attr/actionBarCustomViewDividerColor" />
<include layout="#layout/actionbar_done_button" />
</LinearLayout>
actionbar_done_button.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="?attr/actionButtonStyle"
android:id="#+id/actionbar_done"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView style="?attr/actionBarTabTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingRight="20dp"
android:drawableLeft="?attr/actionBarDoneIcon"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:text="#string/save" />
</FrameLayout>
StockAlertFragmentActivity.java
public class StockAlertFragmentActivity extends SherlockFragmentActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Inflate a "Done/Discard" custom action bar view.
LayoutInflater inflater = (LayoutInflater) this.getSupportActionBar().getThemedContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
final View customActionBarView = inflater.inflate(
R.layout.actionbar_custom_view_done_discard, null);
The outcome is as following, when we tap on the SAVE button.
However, after migrating our app to material designed app (targetSdkVersion 23, theme Theme.AppCompat.Light.NoActionBar), system attribute attr/actionButtonStyle no longer work well with rectangle button.
Instead, it draws a round overlay on the top of rectangle button.
toolbar_with_save_discard.xml
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:contentInsetLeft="0dp"
android:contentInsetStart="0dp"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
android:contentInsetRight="0dp"
android:contentInsetEnd="0dp"
app:contentInsetRight="0dp"
app:contentInsetEnd="0dp"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" >
<!-- android:elevation="4dp" is used due to http://www.google.com/design/spec/what-is-material/elevation-shadows.html#elevation-shadows-elevation-android- -->
<LinearLayout
android:id="#+id/buttons_linear_layout"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:orientation="horizontal">
<include layout="#layout/toolbar_discard_button" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:background="?attr/toolbarCustomViewDividerColor" />
<include layout="#layout/toolbar_save_button" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
toolbar_save_button.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="?attr/actionButtonStyle"
android:id="#+id/toolbar_save"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView style="?attr/actionBarTabTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingRight="20dp"
android:drawableLeft="?attr/toolbarDoneIcon"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:text="#string/save" />
</FrameLayout>
I like to have the overlay drawn on the entire rectangle SAVE button.
I think most probably I can solve this, by avoiding from using style="?attr/actionButtonStyle", and supplying my very own defined selector.
However, I prefer not to do so. I prefer to use system provided style, for less maintenance headache.
How can I make style="?attr/actionButtonStyle" workable for rectangle toolbar button?
Or, Is there any other system style attribute, which will work well with rectangle toolbar button? At the same time, having ripple effect.
Attribute at play here is: actionButtonStyle which you set on your wrapping FrameLayout. On v23, it points to:
<style name="Widget.Material.ActionButton">
<item name="background">?attr/actionBarItemBackground</item>
<item name="paddingStart">12dp</item>
<item name="paddingEnd">12dp</item>
<item name="minWidth">#dimen/action_button_min_width_material</item>
<item name="minHeight">#dimen/action_button_min_height_material</item>
<item name="gravity">center</item>
<item name="scaleType">center</item>
<item name="maxLines">2</item>
</style>
The background is set to actionBarItemBackground which in turn points to this RippleDrawable:
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?attr/colorControlHighlight"
android:radius="20dp" />
The radius value is what you don't want.
To fix this, override actionBarItemBackground under your app's theme:
<style name="AppTheme" parent="....">
....
<item name="actionBarItemBackground">#drawable/custom_action_bar_item_bg</item>
<item name="android:actionBarItemBackground">#drawable/custom_action_bar_item_bg</item>
</style>
The drawable custom_action_bar_item_bg would be defined as:
res/drawable/custom_action_bar_item_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<color android:color="#...."/>
</item>
<item>
<color android:color="#android:color/transparent"/>
</item>
</selector>
res/drawable-v21/custom_action_bar_item_bg.xml
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?attr/colorControlHighlight">
<item android:id="#id/mask">
<color android:color="#android:color/white" />
</item>
</ripple>
The mask is what will give you the rectangle in case of API version > 21.
The downside: all items that use actionBarItemBackground will be affected (unless if that's okay). To fix this, you can create a separate theme to set on your FrameLayout wrapper. For example, this is your app's main theme:
<style name="AppTheme" parent="....">
....
....
</style>
Create another theme that inherits from AppTheme:
<style name="SelectiveActionBarButtonTheme" parent="AppTheme">
<item name="actionBarItemBackground">#drawable/custom_action_bar_item_bg</item>
<item name="android:actionBarItemBackground">#drawable/custom_action_bar_item_bg</item>
</style>
To use this, override android:theme on your wrapper FrameLayout:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="?attr/actionButtonStyle"
android:id="#+id/toolbar_save"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:theme="#style/SelectiveActionBarButtonTheme">
....
....
</FrameLayout>
And of course, the simplest approach would be to set FrameLayout's android:background to ?attr/selectableItemBackground, and be done with it.
I would like to have a bigger action bar.
So I change the action bar size in the style, and now I am looking for changing the icon size and put the text bigger also.
Here is my style :
<!-- Application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:textSize">22sp</item>
<item name="android:actionBarSize">100dp</item>
<item name="android:actionBarTabTextStyle">#style/MyActionBarTabText</item>
<item name="android:actionButtonStyle">#style/MyActionButtonStyle</item>
</style>
<style name="MyActionButtonStyle" parent="android:style/Widget.ActionButton">
<item name="android:layout_width">fill_parent</item>
</style>
<style name="MyActionBarTabText" parent="android:style/Widget.Holo.ActionBar.TabText">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">25dp</item>
</style>
And my menu for the actionBar (menu.xml) :
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/app_setting"
android:title="#string/app_setting"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:icon="#drawable/ic_setting"
android:showAsAction="ifRoom" />
</menu>
And In the main class :
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
return true;
}
Also, I tried several questions, but I was not able to make it work.
I want to change actionbar icon size
How to change actionBar icon size?
The best solution is to implement Toolbar in your layout and put TextView and define attributes on it.
Here is my solution.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay"
tools:ignore="MissingConstraints">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="#style/Theme.MyTest"
app:popupTheme="#style/Theme.MyTest">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:textAppearance="#style/TextAppearance.Widget.AppCompat.Toolbar.Title"
android:textColor="#color/white"
android:textSize="#dimen/title_size" />
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/nav_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="#menu/bottom_nav_menu" />
<fragment
android:id="#+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
android:layout_marginTop="?attr/actionBarSize"
app:layout_constraintBottom_toTopOf="#id/nav_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="#navigation/mobile_navigation" />
</androidx.constraintlayout.widget.ConstraintLayout>
Here is styles which used in Toolbar attribute.
values\style.xml
...
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
...
With this way, you will have chance to change the Title color and size as you want.
While importing the icon from Vector Asset, setting the size depending on your requirement will do the job.