If you want to trace the name of the method that’s being executed, the Java code snippet in this page might help you. This is especially handy when you are debugging by tracking every method that is executed. You can enclose these lines of codes in a function that you call in every method — […]
coding
Android: underline text in your app
When I need to underline text in an app that I’m developing, I like doing it programmatically. The code is in the Java file, not in the XML. Maybe we should make a function for this where we pass the ID of the TextView whose content we’d like to underline.
1 2 3 |
TextView myTextView = (TextView) findViewById(R.id.myTextViewID); String htmlString = "<u>" + myTextView.getText() + "</u>"; myTextView.setText(Html.fromHtml(htmlString)); |
Disadvantages in this method: […]
Android: dimensions cheat sheets for graphic designers AND developers
Just sharing the link to a “cheat sheet” that I found: Android Cheatsheet for Graphic Designers I think that this resource should have been said to be for developers too, because developers need to know about dimensions of graphics in the Android apps they develop.
Android transparent overlay without View
We’re not going to use ViewOverlay here. We’ll use Dialog instead. The overlay does not show on button click. What I did was let the overlay appear when the activity is loaded. First, create the XML file for the contents of that dialog overlay. \app\src\main\res\layout\popup_content.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:background="#78000000" android:padding="@dimen/activity_margin" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:textColor="#ffffff" android:text="This is your dialog with transparent background." android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:id="@+id/btn_close_overlay" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/colorPrimary" android:textColor="#ffffff" android:text="Dismiss"/> </LinearLayout> |
Then add the following code into your activity’s Java […]
Android app dev: background image sizes for different screen sizes
Here are the recommended background image sizes in pixels for Android app development: xxxhdpi: 1280×1920 px xxhdpi: 960×1600 px xhdpi: 640×960 px hdpi: 480×800 px mdpi: 320×480 px ldpi: 240×320 px …as suggested in this StackOverflow page: Android: Background Image Size (in Pixel) which Support All Devices

Get started: Android Studio app development on Windows 7 (Tested on LG G3 phone)
You can still follow this tutorial if you’re using another version of Windows or if you’re using another Android device. You don’t strictly have to use a Windows 7 computer and an LG G3 phone. 🙂 Being a web developer and a frequent user of Android devices, I’ve always been curious about Android app development. […]
Android: 2-dimensional List String (List of List)
For a web developer who used mostly PHP and JavaScript for several years, plunging into Java can be challenging especially when it comes to data types. PHP and JavaScript are loosely typed languages, while Java is strict about types. I was told that in Android, List<String> is very commonly used, even more than arrays. And […]

Android confirm dialog box with OK and Cancel button
This will probably be one of the Android code snippets that I will need to go back to from time to time. I’m sharing the codes we need to show an Android confirm dialog to prompt the user to click “yes” or “no”, or in my case, “OK” or “Cancel”. The following code for Android […]

Android Studio dark theme (change into Darcula theme)
You might feel more comfortable with a dark theme in Android Studio, but the default theme is light in color. I’m one of the developers who always code in dark screens since it’s less tiring to the eyes. If you’re like me who prefers dark themes while coding, then I’ll show you how to change […]

Google Maps get coordinates on click or drag and drop
With this tutorial you’ll see how we can place a Google map with search box on your web page, and then get coordinates (i.e. latitude and longitude) based on where you click or where you drag and drop the marker into. The JavaScript API of Google Maps will help us achieve this. This kind of […]