Found 1626 Articles for Android

How to implement a custom AlertDialog View in Android?

Azhar
Updated on 15-Nov-2019 12:23:59

1K+ Views

This example demonstrates how to implement a custom AlertDialog View in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to res/layout/my_dialog.xml.                           Step 4 − Add the following code to res/drawable/button_background.xml.                                   ... Read More

What is the height of the status bar in Android?

Azhar
Updated on 15-Nov-2019 12:14:57

3K+ Views

This example demonstrates how to height of the status bar in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javapackage com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.content.res.Resources; import android.os.Bundle; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       getStatusBarHeight();    }    private int getStatusBarHeight() ... Read More

How to animate RecyclerView items when they appear on screen?

Azhar
Updated on 15-Nov-2019 12:11:51

1K+ Views

This example demonstrates how to animate RecyclerView items when they appear on the screen .Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to res/anim/down_to_up.xml.         Step 4 − Add the following code to res/anim/left_to_right.xml.         Step 5 − Add the following code to res/anim/right_to_left.xml.         Step 6 − Add the ... Read More

How to make the corners of a button round in Android?

Azhar
Updated on 15-Nov-2019 11:59:19

4K+ Views

This example demonstrates how to make the corners of a button round in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javapackage com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    } }Step 4 − Add the following code to res/drawable/mybutton.xml.       ... Read More

How to how to customize snackBar's layout in Android?

Azhar
Updated on 15-Nov-2019 11:55:11

416 Views

This example demonstrates how to customize snackBar's layout in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javapackage com.androidmads.ajts.customsnackbar; import android.graphics.Color; import android.graphics.Typeface; import android.os.Build; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Gravity; import android.view.View; import android.widget.Button; import android.widget.FrameLayout; import android.widget.TextView; import static java.security.AccessController.getContext; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);   ... Read More

How to change the background color of the options menu in Android?

Azhar
Updated on 15-Nov-2019 11:50:46

7K+ Views

This example demonstrates how to change the background color of the options menu in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to res/menu/menu_items.xml             Step 4 − Add the following code to res/values/styles.xml           @color/colorPrimary       @color/colorPrimaryDark       @color/colorAccent       @color/colorPrimary       @color/skyBlue ... Read More

How to lay out Views in RelativeLayout programmatically in Android?

Azhar
Updated on 09-Jul-2020 06:41:14

869 Views

This example demonstrates how to lay out Views in RelativeLayout programmatically in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javapackage com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.RelativeLayout; import android.widget.RelativeLayout.LayoutParams; import android.widget.Toast; public class MainActivity extends Activity {    RelativeLayout relativelayout;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);     ... Read More

How to make surfaceview transparent in an Android App?

Azhar
Updated on 15-Nov-2019 11:28:08

992 Views

This example demonstrates how to make surfaceview transparent in an Android App.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.javapackage com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    } }Step 4 − Add the following code to Manifests/AndroidManifest.xml     ... Read More

How to change colors of a Drawable in Android?

Azhar
Updated on 15-Nov-2019 11:24:26

3K+ Views

This example demonstrates how to change the colors of a Drawable in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javapackage com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.graphics.drawable.AnimationDrawable; import android.os.Bundle; import android.widget.LinearLayout; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       LinearLayout your_Layout = (LinearLayout) findViewById(R.id.activity_main);       AnimationDrawable animationDrawable ... Read More

How to set Android Toast duration longer than Toast.LENGTH_LONG?

Azhar
Updated on 15-Nov-2019 11:11:12

1K+ Views

This example demonstrates how to set Android Toast duration longer than Toast.LENGTH_LONG.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.javapackage com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.os.CountDownTimer; import android.view.View; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    }    private Toast mToastToShow;    public ... Read More

Advertisements