Skip to main content

Posts

android - RecyclerView in different screen size and orientation example

activity_main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/root_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#c7c9bf" > <android.support.v7.widget.RecyclerView android:id="@+id/recycler_view" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout> MainActivity.java package com.cfsuman.me.androidcodesnippets; import android.app.Activity; import android.content.Context; import android.content.res.Configuration; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.GridLayoutManager; import android.support.v7…
Recent posts

android - XmlPullParser to parse xml attribute

activity_main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/root_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="16dp" > <TextView android:id="@+id/text_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="16dp" android:padding="10dp" android:textSize="22sp" /> </RelativeLayout> res/raw/students.xml <?xml version="1.0" encoding="utf-8"?> <students> <student section="Science" age="21">Richard Levi</student> <student section=…

android - Upload image into Firebase storage example

activity_main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/root_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="16dp" > <Spinner android:id="@+id/spinner" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top|start" /> <ImageView android:id="@+id/image_view_local" android:layout_width="match_parent" android:layout_height="200dp" android:layout_below="@id/spinner" android:scaleType="centerCrop" /> <Button android:id="…

android - Firebase crash reporting example

activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/coordinator_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#f7f9f5" > <Button android:id="@+id/btn_red" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Apply Red Text" android:layout_gravity="top|center_horizontal" android:layout_margin="20dp" /> <TextView android:id="@+id/tv" android:layout_width="wrap_content" android:layout_height="wrap_content" andr…

android - Firebase Realtime database example

activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/coordinator_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#bcbcbc" > <LinearLayout android:id="@+id/ll" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_gravity="top|center_horizontal" android:layout_margin="50dp" > <Button android:id="@+id/btn_red" android:layout_width="wrap_content" android:layout_height="wrap_cont…

android - Firebase remote config example

activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/coordinator_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#abe19f" > <TextView android:id="@+id/tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:textSize="30sp" /> </android.support.design.widget.CoordinatorLayout> MainActivity.java package com.cfsuman.me.androidcodesnippets; import android.app.Activity; import android.content.Context; import android.graphics.Color; import android.support.design.widg…

android - Text and background color animation example

activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/coordinator_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:id="@+id/btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Click Me" android:layout_margin="25dp" android:padding="20dp" android:layout_gravity="center" android:gravity="center" /> <TextView android:id="@+id/tv" android:layout_width="wrap_content" android:layout_height="wrap_content" …