2

I want to modify my action bar. I want action bar with round edges.

I am providing some information about action bar and Theme style. Hope you understand what i want

my themes.xml



    <resources xmlns:tools="http://schemas.android.com/tools">
        <!-- Base application theme. -->
        <style name="Theme.AIT" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
            <!-- Primary brand color. -->
            <item name="colorPrimary">@color/purple_500</item>
            <item name="colorPrimaryVariant">@color/purple_700</item>
            <item name="colorOnPrimary">@color/white</item>
            <!-- Secondary brand color. -->
            <item name="colorSecondary">@color/teal_200</item>
            <item name="colorSecondaryVariant">@color/teal_700</item>
            <item name="colorOnSecondary">@color/black</item>
            <!-- Status bar color. -->
            <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
            <!-- Customize your theme here. -->
         
        </style>

        <style name="Theme.AIT.NoActionBar">
            <item name="windowActionBar">false</item>
            <item name="windowNoTitle">true</item>
        </style>




        <style name="Theme.AIT.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

        <style name="Theme.AIT.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
    </resources>

Here i am providing toolbar.xml

Here is coding of toolbar. I have created this toolbar with sky blue (#2398f4) background color.




    <?xml version="1.0" encoding="utf-8"?>
    <androidx.coordinatorlayout.widget.CoordinatorLayout 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">

        <com.google.android.material.appbar.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:elevation="0dp"

            android:theme="@style/Theme.AIT.AppBarOverlay">

            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar"
    android:elevation="2dp"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="#2398f4"

                app:popupTheme="@style/Theme.AIT.PopupOverlay"
                app:elevation="0dp"
               >

            </androidx.appcompat.widget.Toolbar>

        </com.google.android.material.appbar.AppBarLayout>

        <include layout="@layout/content_main" />

    </androidx.coordinatorlayout.widget.CoordinatorLayout>

Help me to create action bar with round edges.

Buddy
  • 581
  • 2
  • 11
  • Does this answer your question? [ActionBar with rounded edges](https://stackoverflow.com/questions/30417161/actionbar-with-rounded-edges) – HB. Nov 22 '20 at 08:32
  • NO @HB. i have already seen this question but does not know how to implement – Buddy Nov 22 '20 at 10:54

1 Answers1

1

The following is only an example of how to wrap a Toolbar with a CardView to make it round edged:

<!-- Use a normal CardView instead of my implementation -->
<xallosh.xproject.xmusic.views.MusicCardView
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:layout_gravity="center"
        android:padding="4dp"
        android:layout_margin="4dp"
        android:layout_centerHorizontal="true"
        app:musicCardUseCompatPadding="true"
        app:musicCardBackgroundColor="?colorPrimary"
        app:musicCardCornerRadius="5dp"
        app:musicCardElevation="4dp"
        app:musicCardPreventCornerOverlap="false">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

             <!-- Use a normal Toolbar here -->
            <xallosh.xproject.xmusic.search.ToolBar
                android:id="@+id/mMainbar"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:gravity="center"
                android:visibility="visible">

                <RelativeLayout
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <ImageView
                        android:id="@+id/search_icon"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:padding="4dp"
                        android:visibility="gone"
                        android:tint="?attr/iconColor"
                        android:background="?attr/selectableItemBackgroundBorderless"
                        android:src="@drawable/ic_action_search"
                        android:layout_alignParentLeft="true"
                        android:layout_centerVertical="true"
                        android:layout_centerHorizontal="true"/>

                    <TextView
                        android:id="@+id/toolbar_title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:fontFamily="sans-serif"
                        android:text="My Library"
                        android:singleLine="true"
                        android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
                        android:layout_centerInParent="true"
                        android:layout_centerHorizontal="true"
                        android:layout_centerVertical="true"/>

                </RelativeLayout>

            </xallosh.xproject.xmusic.search.ToolBar>

        </RelativeLayout>

    </xallosh.xproject.xmusic.views.MusicCardView>

enter image description here

private static
  • 745
  • 8
  • 17
  • if i use your coding my app will not work because everything will change. and i am in middle of my app – Buddy Nov 22 '20 at 12:06
  • If you really want to help me then please let's connect on social media. Instagram - mr.trader57 – Buddy Nov 22 '20 at 12:23
  • Hey brother check my new question https://stackoverflow.com/questions/65024641/download-pdf-and-open-it-in-google-doc-with-download-notification @Prince Ali – Buddy Nov 27 '20 at 10:22