android app bar material design
Bottom App Bar for Android - A Material Design Component
Similar to an App Bar (Top App Bar or Toolbar), Google introduced the Bottom App Bar as part of the Material Design Components back in 2018.
Let's get into the implementation by adding a dependency to the build.gradle file.
implementation "com.google.android.material:material:1.2.0-alpha03" In the next step, let's add the BottomAppBar and the FloatingActionButton to the activity layout.
<com.google.android.material.bottomappbar.BottomAppBar android:id="@+id/bottomAppBar" style="@style/Widget.MaterialComponents.BottomAppBar.PrimarySurface" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" app:hideOnScroll="true" app:fabAnimationMode="slide" app:menu="@menu/menu_main" app:navigationIcon="@drawable/ic_menu_white" /> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/createFab" android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_anchor="@+id/bottomAppBar" app:srcCompat="@drawable/ic_create_white" /> That's it, you can see the Bottom App Bar in the preview with the Floating Action Button hovering over the cradle.
There are a few tags and points to be remembered before we continue the implementation.
Never use a Bottom App Bar with one action like shown in the above case. Keep the action count between two to five similar to Bottom Navigation View.
Don't use background attribute to change the background color of the Bottom App Bar, use backgroundTint as the earlier is ineffective.
layout_anchor tag is used to anchor the Floating Action Button with the Bottom App Bar.
fabAlignmentMode has center and end attributes. By default, the value is set as the center and this value decides whether the floating action button is shown at the center or end.
navigationIcon - This sets the navigation icon for the Bottom App Bar. You can use any icon other than the back icon as a back icon can only be added to the Top App Bar (or Toolbar).
app:hideOnScroll hides the Bottom App Bar when the list items on the screen are scrolled.
Furthermore, the Cradle under the Bottom App Bar and the position of the Floating Action Button can be controlled using app:fabCradleMargin, app:fabCradleRoundedCornerRadius and app:fabCradleVerticalOff.
This finishes the integration of the Bottom App Bar in the application. In the next week's article, we will take a look at adding click listeners to the menu items and show a navigation drawer when the navigation menu is clicked.
Popular posts from this blog
Add Spacing to Recycler View Linear Layout Manager Using Item Decoration
In this article we will learn about, item decoration in Android and how we can use it to add even spacing between the child items. A RecyclerView without spacing will look like the image below but in most cases, we want to add spacing between the items. [You can see there are no margins between the views and only elevation] A more traditional option is adding margins in the list item xml file. If we take this route, we will soon end up with uneven spacing issues with vertical margins. [There are even left, right, top, bottom margins for all the rows except the last item in the first image and in the subsequent image, the top margin for the first item is half of the other items] The best way is to add the ItemDecoration to the RecyclerView as it affects the individual items and you can have more control over them. Kotlin: /** * Add vertical, horizontal spacing to the recycler view */ class DefaultItemDecorator(private val horizontalSpacing: Int,
How to Change Material Chip Text Size, Text Style and Font
Chips in Android is a Material Design Component used primarily for actions or choice or during filters or as an input. The attributes like textColor , textStyle and fontFamily are ignored when added to the Material Chips directly. We need to modify these values using textAppearance . <com.google.android.material.chip.Chip android:id="@+id/maleChip" style="@style/Widget.MaterialComponents.Chip.Choice" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checkable="true" android:layoutDirection="locale" android:text="@string/chip_text_male" android:textAppearance="@style/AppTheme.GenderChip" android:textColor="@color/colorWhiteText" app:chipBackgroundColor="@drawable/select_chip" app:chipEndPadding="@dimen/chip_horizontal_margin" app:chipStartPadding="@dimen/chip_horizontal_margin&quo
How to Read Metadata from AndriodManifest File
Metadata tags are key-value pairs and one of the decent ways to access the API keys from the libraries. They are added to the AndroidManifest.xml under the application tag and are available through the PackageManager . If you have worked with third-party libraries or even with App shortcuts, Downloadable Fonts, Firebase MLKit, you may have come across metadata tags. In the article, let's add the metadata tags to the app module's Manifest file and read the metadata key-values and the key-resource from a library module both in kotlin and java. Add meta-data: Add metadata to the app module's AndroidManifest.xml file under the application tag. You can add as many metadata elements as you want and you can also add metadata under the activity, service, broadcast receiver, content provider tags. <meta-data android:name= "com.gsrikar.library.LIBRARY_ACCESS_KEY" android:value= "masndfiu4er9funwikesd" /> <meta-data and
How to Set an Android App as a Default Dialer
A default dialer is an application that handles the Phone calls on the device. Google made the provision for third-party applications to be a default phone handler from SDK 23 (6.0, Marshmallow version). In the article, we will learn about how to set our Android application as a default dialer. 1) Add the below intent filters under the activity tag in the AndroidManifest.xml. <intent-filter> <action android:name="android.intent.action.DIAL"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> <intent-filter> <action android:name="android.intent.action.DIAL"/> <category android:name="android.intent.category.DEFAULT"/> <data android:scheme="tel"/> </intent-filter> 2) Check if our application is already a default dialer app using TelecomManager. val telecomManager = getSystemService(Context.TELECOM_SERVICE) as TelecomManager Log
Create Assets Folder, Add Files and Read Data From It
Sometimes, we need to read the data stored in the files during runtime and want to make sure the data is not tampered by the Android build system. In this article, we will take a look at how to create the assets folder using Android Studio and read the stored data from it. First, Right-click on the module name or the package name. This opens an option window where we need to select the Assets Folder option by hovering over New and then on the Folder option. Now, we will see a window where we change the folder location and the source set. Change the values if necessary otherwise keep the defaults and click Finish. It may trigger a Gradle Sync. Irrespective of the sync, the Assets folder is created and is visible in the module. Now, Right-click on the Assets folder and click on the File option by hovering over the New option. Enter the name of the file name and click Enter to create the file. The file with the name user_details.json is created under the assets folder. Add some JSON
android app bar material design
Source: https://www.gsrikar.com/2020/01/bottom-app-bar-for-android-material.html
Posted by: moandin1942.blogspot.com

0 Response to "android app bar material design"
Post a Comment