programming

All About My Custom Hugo Theme KMT

My ToDo List for 2024 (daily updates)

waffarx cash back

Adding GIF image in an ImageView in android

use android-gif-drawable library 🔗 add the following dependency to build.gradle file of your project. dependencies { implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19' } Use the view in XML file like this. <pl.droidsonroids.gif.GifImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/src_anim" android:background="@drawable/bg_anim" /> For more customization and code, see the docs here . use VideoView on Android 🔗 You can use VideoView to show the GIF image. But the library is more efficient and smooth. use ImageView on Android 🔗 Use ImageView and Split the GIF file into several images and then apply animation to it.

How to make imageview over another view in Android ?

There are at least 3 ways to put imageview on another imageview. Simple Order 🔗 This way is just put the imageview after the other imageview in XML file. It is simple like that. The first view will be underneath the second one. Using FrameLayout 🔗 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" > <ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/t" /> <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" /> </FrameLayout> The second image will be on top.

Comparing Two Integers in C Programming Language

Here is the code snippet in C programming language. #include <stdio.h> int main() { int a, b; a = 11; b = 99; // to take values from user input uncomment the below lines − // printf("Enter value for A :"); // scanf("%d", &a); // printf("Enter value for B :"); // scanf("%d", &b); if(a > b) printf("a is greater than b"); else printf("a is not greater than b"); return 0; }

Elixir Cheatsheet - Elixir in Brief

Elixir is a dynamic functional compiled language that runs over an Erlang Virtual Machine called BEAM. Erlang and its BEAM is well known for running low-lattency, distributed and fault-tolerant applications. Elixir was designed to take all that advantages in a modern coding language. Elixir data types are immutable. In Elixir a function is usually described with its arity (number of arguments), such as: is_boolean/1. File Types 🔗 .exs => Elixir script file .

Python Cheatsheet

Python sys Variables 🔗 variable meaning argv Command line args builti­n_m­odu­le_­names Linked C modules byteorder Native byte order check_­int­erval Signal check frequency exec_p­refix Root directory executable Name of executable exitfunc Exit function name modules Loaded modules path Search path platform Current platform stdin, stdout, stderr File objects for I/O versio­n_info Python version info winver Version number Python sys.argv 🔗 sys.argv for the command: python foo.py bar -c qux --h sys.

PHP cheatsheet

PHP Array Functions 🔗 array_diff (arr1, arr2 …) array_filter (arr, function) array_flip (arr) array_intersect (arr1, arr2 …) array_merge (arr1, arr2 …) array_pop (arr) array_push (arr, var1, var2 …) array_reverse (arr) array_search (needle, arr) array_walk (arr, function) count (count) in_array (needle, haystack) PHP String Functions 🔗 crypt (str, salt) explode (sep, str) implode (glue, arr) nl2br (str) sprintf (frmt, args) strip_tags (str, allowed_tags) str_replace (search, replace, str) strpos (str, needle) strrev (str) strstr (str, needle) strtolower (str) strtoupper (str) substr (string, start, len) PHP Filesystem Functions 🔗 clearstatcache () copy (source, dest) fclose (handle) fgets (handle, len) file (file) filemtime (file) filesize (file) file_exists (file) fopen (file, mode) fread (handle, len) fwrite (handle, str) readfile (file) PHP Date and Time Functions 🔗 checkdate (month, day, year) date (format, timestamp) getdate (timestamp) mktime (hr, min, sec, month, day, yr) strftime (formatstring, timestamp) strtotime (str) time () PHP Regular Expres­sions Functions 🔗 ereg (pattern, str) split (pattern, str) ereg_replace (pattern, replace, str) preg_grep (pattern, arr) preg_match (pattern, str) preg_match_all (pattern, str, arr) preg_replace (pattern, replace, str) preg_split (pattern, str) Regular Expres­sions Syntax 🔗 regex meaning ^ Start of string $ End of string .

How to get currently running applications in android ?

Use this code in your app’s `src/MainActivity.kt’ file. import android.app.ActivityManager import android.app.ActivityManager.RunningTaskInfo import android.content.Context import android.os.Bundle import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import java.util.* class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) title = "KotlinApp" val textView: TextView = findViewById(R.id.textView) val activityManager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager val recentTasks: List<RunningTaskInfo> = Objects.requireNonNull(activityManager).getRunningTasks(Int.MAX_VALUE) for (i in recentTasks.indices) { textView.text = "Application executed: ${recentTasks[i].baseActivity!!.toShortString()}ID: ${recentTasks[i].id}" } } } Make sure you have a TextView with id textView in your XML layout.

Should I use Swift or Objective-C to learn iOS development ?

The Swift programming language is the standard features rich language to create iOS apps, iPadOS apps and MacOS X apps. The present and the future is just Swift on Apple ecosystem. Apple is perfecting Swift every year with updates and new features and capabilities. We are now in the era of SwiftUI, you should go for Swift already. Swift itself is a robust programming language. So go for it! it is standard for hiring, learning, creating apps for Apple operating systems.

How to animate the change of background color of a view on iOS ?

Step by step guide to create background color changing with beautiful animation 🔗 open Main.storyboard add a button as shown below add one @IBAction for touchUpInside of ‘Change Background’ button. Name the function as changeBackgroundClicked. use animate function of UIView to animate the change of background color. It provides us the duration and optional completion as parameters. In changeBackgroundClicked we will change the background color of the view from red to blue and vice versa.

How do you animate the change of background color of a view on Android ?

The idea is to use this code snippet. ColorDrawable[] colorDrawables = { new ColorDrawable(Color.RED), new ColorDrawable(Color.BLUE), new ColorDrawable(Color.GREEN) }; TransitionDrawable transitionDrawable = new TransitionDrawable(colorDrawables); textView.setBackground(transitionDrawable); transitionDrawable.startTransition(2000); In this code snippet, we created a list of colorDrawables, then feed them to the TransitionDrawable. And now we have an animating color change, so we pass it to the setBackground to get the animating colors in the background. Got the idea ? let’s create a complete code example.