Found 1626 Articles for Android

How can I set an ImageView's width and height programmatically in Android?

Azhar
Updated on 31-Jul-2019 11:36:38

4K+ Views

This example demonstrates about How can I set an ImageView's width and height programmatically in AndroidStep 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 app.com.sample; import android.os.Bundle; import android.widget.ImageView; import android.widget.RelativeLayout; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       RelativeLayout rlMain = findViewById(R.id.rlMain);       ImageView ... Read More

How to set an Android App's background image repeated?

Azhar
Updated on 31-Jul-2019 11:32:54

1K+ Views

This example demonstrates about How to set an Android App's background image repeatedStep 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/drawable/app_background.xml. Step 2 − Add the following code to res/values/styles.xml.           @color/colorPrimary       @color/colorPrimaryDark       @color/colorAccent       @drawable/app_background     Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javapackage app.com.sample; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; public class ... Read More

How can we get the current language selected in the Android device?

Azhar
Updated on 31-Jul-2019 11:28:06

159 Views

This example demonstrates about How can we get the current language selected in the Android deviceStep 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.

How do I center text horizontally and vertically in a TextView of Android?

Azhar
Updated on 31-Jul-2019 11:23:53

2K+ Views

This example demonstrates about How do I center text horizontally and vertically in a TextView of AndroidStep 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 app.com.sample; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; 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 ... Read More

How to send HTML email using Android App?

Azhar
Updated on 31-Jul-2019 11:17:57

1K+ Views

This example demonstrates about How to send HTML email using 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 app.com.sample; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.text.Html; import android.view.View; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    }    public void sendHtmlEmail(View view) { ... Read More

How to create paginating text in Android?

Azhar
Updated on 31-Jul-2019 11:13:08

305 Views

This example demonstrates about How to create paginating text 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 app.com.sample; import android.graphics.Color; import android.graphics.Typeface; import android.os.Bundle; import android.text.Html; import android.text.Spannable; import android.text.SpannableString; import android.text.Spanned; import android.text.TextUtils; import android.text.style.ForegroundColorSpan; import android.text.style.RelativeSizeSpan; import android.text.style.StyleSpan; import android.view.View; import android.view.ViewTreeObserver; import android.widget.TextView; import androidx.appcompat.app.AppCompatActivity; public ... Read More

How to check current running applications in Android?

Azhar
Updated on 31-Jul-2019 10:57:15

993 Views

This example demonstrates about How to check current running applications in AndroidStep 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 app.com.sample; import android.app.ActivityManager; import android.content.Context; import android.os.Bundle; import android.widget.TextView; import androidx.appcompat.app.AppCompatActivity; import java.util.List; import java.util.Objects; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       TextView textView = ... Read More

How to implement a long click listener on a Android listview?

Azhar
Updated on 31-Jul-2019 10:49:04

2K+ Views

This example demonstrates about How to implement a long click listener on a Android listview.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 app.com.sample; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity {    String[] mobileArray = {"Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X"};    @Override    protected void ... Read More

How to launch activity only once when Android app is opened for the first time?

Azhar
Updated on 31-Jul-2019 10:43:59

870 Views

This example demonstrates about How to launch activity only once when Android app is opened for the first time.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 app.com.sample; import androidx.appcompat.app.AppCompatActivity; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; public class MainActivity extends AppCompatActivity {    String prevStarted = "prevStarted";    @Override    protected void onResume() {       super.onResume();       SharedPreferences sharedpreferences ... Read More

How to store drawable resources ID in the form of R.drawable.* inside an array using an XML values file?

Azhar
Updated on 31-Jul-2019 10:36:07

1K+ Views

This example demonstrates about How to store drawable resources ID in the form of R.drawable.* inside an array using an XML values fileStep 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/values/ arrays.xml.           @drawable/image1       @drawable/image2       @drawable/image3     Step 3 − Add the following code to res/layout/activity_main.xml.             Step 4 − Add the following code to src/MainActivity.javapackage app.com.sample; ... Read More

Advertisements