Posts
To include Shimmer in your project, add the following dependency: // Gradle dependency on Shimmer for Android dependencies { implementation 'com.facebook.shimmer:shimmer:0.5.0' } ======================================================== Usage in layout -------------------------------------------------------------------------- <com.facebook.shimmer.ShimmerFrameLayout android:id="@+id/shimmer_view_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginTop="10dp" android:orientation="vertical" app:shimmer_duration="800"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <include layout="
Setup Genymotion in Windows Source Official Site : Genymotion Genymotion Desktop relies on the use of Oracle VM VirtualBox in the background to virtualize Android operating systems. If you do not already have Oracle VM VirtualBox installed, you will be asked to do so prior to installing Genymotion. To install Genymotion, follow the steps corresponding to your operating system. Windows Go to the Genymotion download page . From this page, you can: Download the ready-to-run Genymotion installer for Windows (recommended, 64bit only). This package includes Oracle VM VirtualBox installer. download the Windows 32/64-bit package. In this case, you must first download and install VirtualBox for Windows hosts from the Download VirtualBox page. WARNING Since VirtualBox 6.0, Oracle has stopped providing support for 32bit Windows. If you use Windows 7,8 or 10 32bit, you have to use VirtualBox 5.2.32 from here WARNING When installing VirtualBox, in
Speeding Up Android Studio by Maximizing heap size Maximum heap size Source: https://developer.android.com/ By default, Android Studio has a maximum heap size of 1280MB. If you are working on a large project, or your system has a lot of RAM, you can improve performance by increasing the maximum heap size for Android Studio processes, such as the core IDE, Gradle daemon, and Kotlin daemon. Android Studio automatically checks for possible heap size optimizations and notifies you if it detects that performance can be improved. Figure 1. A notification about recommended memory settings. If you use a 64-bit system that has at least 5 GB of RAM, you can also adjust the heap sizes for your project manually. To do so, follow these steps: Click File > Settings from the menu bar (or Android Studio > Preferences on macOS). Click Appearance & Behavior > System Settings > Memory Settings . Adjust the heap sizes to match your desired amounts. Cl
In your Project pane , click on the little gear icon. Uncheck / De-select the Compact Empty Middle Packages option Your package directory will now be broken up in individual directories Individually select each directory you want to rename, and: Right-click it Select Refactor Click on Rename In the Pop-up dialog, click on Rename Package instead of Rename Directory Enter the new name and hit Refactor Click Do Refactor in the bottom Allow a minute to let Android Studio update all changes Note: When renaming com in Android Studio, it might give a warning. In such case, select Rename All Now open your Gradle Build File ( build.gradle - Usually app or mobile ). Update the applicationId in the defaultConfig to your new Package Name and Sync Gradle, if it hasn't already been updated automatically: You may need to change the package= attribute in your manifest. Clean and Rebuild. Done! https://stackoverflow.com/a/290926
Retrofit Make sure to require Internet permissions in your AndroidManifest.xml file: <manifest xmlns:android= "http://schemas.android.com/apk/res/android" > <uses-permission android:name= "android.permission.INTERNET" /> </manifest> Add the following to your app/build.gradle file: dependencies { implementation 'com.google.code.gson:gson:2.8.5' implementation 'com.squareup.retrofit2:retrofit:2.4.0' implementation 'com.squareup.retrofit2:converter-gson:2.4.0' }
Adding header view to recyclerview with gridlayout manager Android Adding header view to recyclerview with gridlayout manager: To add a header to a recyclerview with a gridlayout, first the adapter needs to be told that the header view is the first position - rather than the standard cell used for the content. Next, the layout manager must be told that the first position should have a span equal to the *span count of the entire list. Take a regular RecyclerView.Adapter class and configure it as follows: The same approach can be used add a footer in addition to or instead of a header.
Item OffsetDecoration Item OffsetDecoration for GridLayoutManager in RecycleView. Following example will help to give equal space to an item in GridLayout. Item OffsetDecoration for GridLayoutManager in RecycleView. Following example will help to give equal space to an item in GridLayout. ItemOffsetDecoration.java public class ItemOffsetDecoration extends RecyclerView.ItemDecoration { private int mItemOffset; private int spanCount = 2; public ItemOffsetDecoration(int itemOffset) { mItemOffset = itemOffset; } public ItemOffsetDecoration(@NonNull Context context, @DimenRes int itemOffsetId) { this(context.getResources().getDimensionPixelSize(itemOffsetId)); } @Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { super.getItemOffsets(outRect, view, parent, state); int position = parent.getChildLayoutPosition(view); GridLayoutManager manager = (GridLayoutManager) p
About debugging Debugging is the process of finding and fixing errors (bugs) or unexpected behavior in your code. All code has bugs, from incorrect behavior in your app, to behavior that excessively consumes memory or network resources, to actual app freezing or crashing. Bugs can result for many reasons: Errors in your design or implementation. Android framework limitations (or bugs). Missing requirements or assumptions for how the app should work. Device limitations (or bugs) Use the debugging, testing, and profiling capabilities in Android Studio to help you reproduce, find, and resolve all of these problems. Those capabilities include: The Android monitor (logcat) The Android Studio debugger Testing frameworks such as JUnit or Espresso Dalvik Debug Monitor Server (DDMS), to track resource usage In this chapter you'll learn how to debug your app with the Android Studio debugger, set and view breakpoints, step through your code, and examine variables.