Trending February 2024 # Safe Mode On Android – All You Need To Know # Suggested March 2024 # Top 9 Popular

You are reading the article Safe Mode On Android – All You Need To Know updated in February 2024 on the website We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested March 2024 Safe Mode On Android – All You Need To Know

Safe mode on Android – All You Need to Know

In situations like these, one way is to get rid of all the junk that’s making your device heavy.

While safe mode on Android could be your bet to tackle the issue, you can also try apps that make it easy for you to get rid of junk out of your smartphone in no time at all.

How to Get Rid of Junk in Android Using Apps? Safe Mode, A Special and Powerful mode on Android

This can prove to be quite medicinal, read on to know why?

1. First, What is Safe mode on Android ?

Third party apps like calendars, widgets, heavily skinned launchers and other such apps can slow your Android phone down or worse, they could become a major cause of why your Android phone may be crashing down abruptly. Safe mode on Android prevents any third party apps from popping up on your screen as soon as you turn your smartphone on.

When you boot your Android device in safe mode, your device will only run default apps. It will not run any third-party apps such as any highly intensive widgets that could be crashing your device.

Note: While it does prevent your device from running slow or crashing down, it should not be treated as the final solution.

Having said that, Android safe mode can be considered as a mode using which you can get a clear picture of the issues pertaining to the software of your device that are making your device slow or causing any other issues which can’t be tracked when your device is running under normal circumstances.    

2. How to Turn Safe Mode On in Android ?

The process of turning on the safe mode on Android may differ from one device model to another. Here’s a probable way you can turn on the safe mode –

1. Long press the power button.

2. From the options that pop up on your screen and which prompt you to either “Power off”, “Restart” device or choose “Airplane Mode”, long press “Power off”.

3. What Can be Done In Safe Mode?

As mentioned earlier, Safe mode makes it easy for you to zoom into problematic apps and uninstall them one by one. You can also test your apps to check if they are running smoothly or not. You can particularly uninstall those apps that automatically pop up when you boot your device such as calendars, clocks and other widgets.

You may also have a look at the recently installed apps. This can be useful if you have very recently started to observe issues.

4. How to Turn Off Safe mode on Android?

After you are sure that the safe mode has worked out the magic for you and that now your phone will work smoothly, you may exit this special mode on Android.

To get out of the safe mode on Android follow the simple steps as mentioned below –

1. Long press the power button

2. Select “Restart”

That’s it, the device will now run in normal mode.

To Conclude

Safe mode is a special mode on Android that might not just help fix small issues like testing faulty operations or helping detect faulty apps, it can even detect grave problems like why there’s unusual loss of battery or why the call button is not functioning.

In case you are still facing issues, it may be time to perform a factory reset or contact your phone’s manufacturer.

Subscribe to our YouTube channel to stay updated with tech related information

Quick Reaction:

About the author

Sarang Bhargava

You're reading Safe Mode On Android – All You Need To Know

Amazon 5G: All You Need To Know

Amazon is known for its place as the biggest online retailer in the world, but over the years the company has been investing into other areas of interest, the latest of which is said to be 5G technology.

5G is seen as the future of the tech industry and given Amazon’s role in this industry, it’s no surprise that stories of Amazon 5G are also popping up. What is interesting, though, is why a giant online retailer like Amazon would want to be part of the 5G story that is predominantly a telecommunications thing. But for sure, we’ll find out sooner or later.

That said, let’s check out the stories doing rounds about Amazon 5G and the potential of joining the future telecommunications industry.

Also read:

Amazon and Boost Mobile

Stories of Amazon 5G started showing up after reports emerged that Amazon could buy Boost Mobile from T-Mobile and Sprint to form a fourth carrier that’s needed to see through the much-talked-about merger between the latter two.

The facts that Amazon buying Boost Mobile would allow the retailer to use New T-Mobiles wireless network for 6+ years as well as acquire any wireless spectrum that could be divested are said to be playing a major role in Amazons desire to join the telecommunications industry.

Boost is said to have about 8 million active users, which could be a great starting point for Amazon 5G. Apparently, Amazon will have to pay about $3 billion for this, although the figure could rise to $4.5 billion including wireless spectrum.

Amazon phone calling experience

Amazon started out selling books and has since grown into a one-stop shop for all your shopping needs. The company is also known for not shying away from trying out new ventures – efforts that have led it to offer phone calls via its Echo Connect.

Here, Echo Connect uses your home phone service to allow smart voice speakers that use Alexa to place phone calls. This means the retailer has been building experience already, with the acquisition of a wireless network probably the last piece in the puzzle.

Amazon cloud services

What better way of doing this than taking on carriers like Verizon via a channel that will also take it a giant step ahead of rival cloud providers like Microsoft?

5G-enabled Amazon devices

Amazon has a wide range of devices already selling in the market and apparently, it’s expected to come in with 5G-enabled devices in the future. When these devices arrive, Amazon wants them to connect to its cloud where data is stored and in the event that it also controls wireless network, customers will be able to buy a complete package of 5G devices from one place and vendor

Analyst Colby Synesael believes the idea behind Amazon acquiring Boost Mobile is that “it expects 5G to be integral to cloud services in the future for industries like healthcare and autos, which will use 5G-enabled devices.”

Amazon 5G rumors are also showing up at a time when Amazon in May 2023 revealed plans to set up more than 3000 satellites that will provide internet access to rural places across the globe.

It isn’t the first time that Amazon would be attempting something similar. Over a decade ago, the retailer launched the first Kindle reading device that let users connect to the company’s Whispernet 3G wireless service and download books over the air.

In 2014, the Fire Phone was unveiled to take on the iPhone, but we all know how that turned out.

Whatever Amazon 5G is all about is still a mystery for now, but we’ll definitely get new details about it in the coming weeks.


Excel Vba Msgbox – All You Need To Know!

In Excel VBA, you can use the MsgBox function to display a message box (as shown below):

A MsgBox is nothing but a dialog box that you can use to inform your users by showing a custom message or get some basic inputs (such as Yes/No or OK/Cancel).

Note: In this tutorial, I will be using the words message box and MsgBox interchangeably. When working with Excel VBA, you always need to use MsgBox.

A message box has the following parts:

Title: This is typically used to display what the message box is about. If you don’t specify anything, it displays the application name – which is Microsoft Excel in this case.

Prompt: This is the message that you want to display. You can use this space to write a couple of lines or even display tables/data here.

Button(s): While OK is the default button, you can customize it to show buttons such as Yes/No, Yes/No/Cancel, Retry/Ignore, etc.

As I mentioned, MsgBox is a function and has a syntax similar to other VBA functions.

MsgBox( prompt [, buttons ] [, title ] [, helpfile, context ] )

prompt – This is a required argument. It displays the message that you see in the MsgBox. In our example, the text “This is a sample MsgBox” is the ‘prompt’. You can use up to 1024 characters in the prompt, and can also use it to display the values of variables. In case you want to show a prompt that has multiple lines, you can do that as well (more on this later in this tutorial).

[buttons] – It determines what buttons and icons are displayed in the MsgBox. For example, if I use vbOkOnly, it will show only the OK button, and if I use vbOKCancel, it will show both the OK and Cancel buttons. I will cover different kinds of buttons later in this tutorial.

[title] – Here you can specify what caption you want in the message dialog box. This is displayed in the title bar of the MsgBox. If you don’t specify anything, it will show the name of the application.

[context] – It is a numeric expression that is the Help context number assigned to the appropriate Help topic.

If you’re new to the concept of Msgbox, feel free to ignore the [helpfile] and [context] arguments. I have rarely seen these being used.

Note: All the arguments in square brackets are optional. Only the ‘prompt’ argument is mandatory.

In this section, I will cover the different types of buttons that you can use with a VBA MsgBox.

Before I show you the VBA code for it and how the MsgBox looks, here is a table that lists all the different button constants you can use.

Button Constant Description

vbOKOnly Shows only the OK button

vbOKCancel Shows the OK and Cancel buttons

vbAbortRetryIgnore Shows the Abort, Retry, and Ignore buttons

vbYesNo Shows the Yes and No buttons

vbYesNoCancel Shows the Yes, No, and Cancel buttons

vbRetryCancel Shows the Retry and Cancel buttons

vbMsgBoxHelpButton Shows the Help button. For this to work, you need to use the help and context arguments in the MsgBox function

vbDefaultButton1 Makes the first button default. You can change the number to change the default button. For example, vbDefaultButton2 makes the second button as the default

Note: While going through the examples of creating different buttons, you may wonder what’s the point of having these buttons if it doesn’t have any impact on the code.

Now let’s have a look at some examples of how the different buttons can be displayed in a MsgBox and how it looks.

MsgBox Buttons – vbOKOnly (Default)

If you only use the prompt and don’t specify any of the arguments, you will get the default message box as shown below:

Below is the code that will give this message box:

Sub DefaultMsgBox() MsgBox "This is a sample box" End Sub

Note that the text string needs to be in double quotes.

You can also use the button constant vbOKOnly, but even if you don’t specify anything, it’s taken as default.

MsgBox Buttons – OK & Cancel

If you only want to show the OK and the Cancel button, you need to use the vbOKCancel constant.

Sub MsgBoxOKCancel() MsgBox "Want to Continue?", vbOKCancel End Sub

MsgBox Buttons – Abort, Retry, and Ignore

You can use the ‘vbAbortRetryIgnore’ constant to show the Abort, Retry, and the Ignore buttons.

Sub MsgBoxAbortRetryIgnore() MsgBox "What do you want to do?", vbAbortRetryIgnore End Sub

MsgBox Buttons – Yes and No

You can use the ‘vbYesNo’ constant to show the Yes and No buttons.

Sub MsgBoxYesNo() MsgBox "Should we stop?", vbYesNo End Sub

MsgBox Buttons – Yes, No and Cancel

You can use the ‘vbYesNoCancel’ constant to show the Yes, No, and Cancel buttons.

Sub MsgBoxYesNoCancel() MsgBox "Should we stop?", vbYesNoCancel End Sub

MsgBox Buttons – Retry and Cancel

You can use the ‘vbRetryCancel’ constant to show the Retry and Cancel buttons.

Sub MsgBoxRetryCancel() MsgBox "What do you want to do next?", vbRetryCancel End Sub

MsgBox Buttons – Help Button

You can use the ‘vbMsgBoxHelpButton’ constant to show the help button. You can use it with other button constants.

Sub MsgBoxRetryHelp() MsgBox "What do you want to do next?", vbRetryCancel + vbMsgBoxHelpButton End Sub

Note that in this code, we have combined two different button constants (vbRetryCancel + vbMsgBoxHelpButton). The first part shows the Retry and Cancel buttons and the second part shows the Help button.

MsgBox Buttons – Setting a Default Button

You can use the ‘vbDefaultButton1’ constant to set the first button as default. This means that the button is already selected and if you press enter, it executes that button.

Below is the code that will set the second button (the ‘No’ button) as the default.

Sub MsgBoxOKCancel() MsgBox "What do you want to do next?", vbYesNoCancel + vbDefaultButton2 End Sub

In most cases, the left-most button is the default button. You can choose other buttons using vbDefaultButton2, vbDefaultButton3, and vbDefaultButton4.

Apart from the buttons, you can also customize the icons that are displayed in the MsgBox dialog box. For example, you can have a red critical icon or a blue information icon.

Below is a table that lists the code that will show the corresponding icon.

Icon Constant Description

vbCritical Shows the critical message icon

vbQuestion Shows the question icon

vbExclamation Shows the warning message icon

vbInformation Shows the information icon

MsgBox Icons – Critical

If you want to show a critical icon in your MsgBox, use the vbCritical constant. You can use this along with other button constants (by putting a + sign in between the codes).

For example, below is a code that will show the default OK button with a critical icon.

Sub MsgBoxCriticalIcon() MsgBox "This is a sample box", vbCritical End Sub

If you want to show the critical icon with Yes and No buttons, use the following code:

Sub MsgBoxCriticalIcon() MsgBox "This is a sample box", vbYesNo + vbCritical End Sub

MsgBox Icons – Question

If you want to show a critical icon in your MsgBox, use the vbQuestion constant.

Sub MsgBoxQuestionIcon() MsgBox "This is a sample box", vbYesNo + vbQuestion End Sub

MsgBox Icons – Exclamation

If you want to show an exclamation icon in your MsgBox, use the vbExclamation constant.

Sub MsgBoxExclamationIcon() MsgBox "This is a sample box", vbYesNo + vbExclamation End Sub

MsgBox Icons – Information

If you want to show an information icon in your MsgBox, use the vbInformation constant.

Sub MsgBoxInformationIcon() MsgBox "This is a sample box", vbYesNo + vbInformation End Sub

When using MsgBox, you can customize the title and the prompt messages.

So far, the example we have seen have used Microsoft Excel as the title. In case you don’t specify the title argument, MsgBox automatically uses the title of the application (which has been Microsoft Excel in this case).

You can customize the title by specifying it in the code as shown below:

Sub MsgBoxInformationIcon() MsgBox "Do you want to continue?", vbYesNo + vbQuestion, "Step 1 of 3" End Sub

Similarly, you can also customize the prompt message.

You can also add line breaks in the prompt message.

In the below code, I have added a line break using ‘vbNewLine’.

Sub MsgBoxInformationIcon() End Sub

You can also use the carriage return character – Chr(13) – or line feed – Chr(10) to insert a new line in the prompt message.

Note that you can add a new line to the prompt message only and not the title.

So far, we have seen the examples where we have created message boxes and customized the buttons, icons, title, and prompt.

Below is a table that shows the exact values and the constant returned by the MsgBox function. You don’t need to memorize these, just be aware of it and you can use the constants which are easier to use.

Constant Value

Ok vbOk 1

Cancel vbCancel 2

Abort vbAbort 3

Retry vbRetry 4

Ignore vbIgnore 5

Yes vbYes 6

No vbNo 7

Sub MsgBoxInformationIcon() Result = MsgBox("Do you want to continue?", vbYesNo + vbQuestion) If Result = vbYes Then End If End Sub

Note: When you assign the MsgBox output to a variable, you need to put the arguments of MsgBox function in parenthesis. For example, in the line Result = MsgBox(“Do you want to continue?”, vbYesNo + vbQuestion), you can see that the arguments are within parenthesis.

If you want to further dig into the Message Box function, here is the official document on it.

You May Also Like the Following Excel VBA Tutorials:

Does Oneplus Watch Have Always On Display (Aod)? All You Need To Know

The newly launched OnePlus Watch has been the topic of many discussions on official and unofficial forums and community boards. The furor has to do with Always-On-Display (AOD) – a much-requested feature that the company has been trying hard to deliver for a while now without hurting other components like battery life. But even without it, one cannot help but admire the remarkable smartwatch that OnePlus has delivered. 

That said, there is still a pretty high chance that the smartwatch might get this feature yet. Here is everything that you need to know about the feature that the OnePlus community is dying to see and what the company has to say about it.

What the OnePlus forum FAQ reveals?

Nope, it doesn’t.

Most smartphones nowadays have the AOD feature that lets users see the time without having to move their phones. But a smartphone’s battery life can afford the power that such a feature demands. Having the same on a smartwatch is a different ballgame altogether. 

The 1.39-inch AMOLED display of the OnePlus Watch wakes up as it detects movement, such as when you raise your arm or push the side buttons. But there is always a delay between the action and the response and that is a major inconvenience. Had there been support for AOD, the smartwatch would have truly lived up to the second half of its name. It is still a watch that we’re talking about so it should have its display on all the time, just as regular, non-smart watches do.  

Although the OnePlus Watch didn’t arrive with AOD, a possible over-the-air (OTA) update could change that in the future. The outpour of requests and feedback has forced the company to reconsider the AOD feature. In their One Plus Watch Deep Dive and FAQ, the company revealed its plans for the feature update. 

The biggest hurdle to AOD seems to be the battery life which, as the forum post revealed, could go down by half with this feature. That “could make or break the user’s experience with their smartwatch”. Since OnePlus has made it a point to deliver good in terms of battery life, much work has to go into AOD battery optimization before it sees the light of day.

The OnePlus team is currently assessing AOD’s power consumption and evaluating the likelihood of it being introduced in a future OTA. However, given that the smartwatch can deliver up to 2-weeks of battery life on a single charge, AOD is a viable option to have even if cuts down battery life by half. 

OnePlus Watch Specifications

The AOD feature notwithstanding, the OnePlus Watch has some truly unbelievable specs and features that would make it worth anyone’s money. These include, but are not limited to, Sp02 oxygen saturation monitoring (handy for our pandemic-ridden age), rapid heart rate alerts, stress detection, sedentary reminders, and more than a hundred workout models to keep you in good shape. 

On top of that, the smartwatch has 5ATM water resistance, standalone GPS and Bluetooth for easy navigation and connectivity, and an IP68-certified construction for dust and water resistance. The circular display of the OnePlus Watch has a 2.5D curved glass that nestles in the case smoothly. The watch also substitutes for a remote for those who own the OnePlus TV and turns off the TV automatically if it detects you’ve been asleep for more than half an hour.

The massive 405mAh battery is the best of the lot, delivering up to 24 hours of use with only 5 minutes of charge, thanks to Warp Charge – OnePlus’ fastest charging technology. It is this facet that has kept our hopes up of seeing the AOD become available in a future update. 

Currently, the company is working to optimize the display and increase the frame rate to 50fps. That, along with a possible OTA update for AOD will definitely put a dent in the smartwatch’s battery life. But only time and (continuous user feedback) will tell how soon this will become available. Do let the folks at OnePlus know “how important AOD is to you, considering that it could increase power consumption by almost 50%”.

Mlb On Bally Sports: Everything You Need To Know

Bally Sports is the latest and possibly the most frustrating entrant in the world of sports media. It is the indirect product of Disney’s acquisition of 21st Century Fox in 2023, which led to Fox Regional Sports Network being sold to the Sinclair group and eventually emerge as Bally Sports. This move has caused quite a stir in the sporting world, and not just because the naming right has gone to a casino giant.

For a bunch of reasons, Bally Sports hasn’t been picked up some of the leading service providers across the United States, which is an absolute bummer for the ones who were gearing up to enjoy the ongoing Major League Baseball campaign. If you’re one of the heartbroken MLB fans, this piece might help you attain some sense of clarity: tell you all about MLB on Bally Sports. 

Related: What Channel Is Bally Sports On Directv/Spectrum?

Can you watch all MLB games on Bally Sports? 

Regional Sports Networks or RSNs are a big deal in the country. They have the capability to outmuscle the national telecast schedule and block the feed of your local team on national television. You either pay for the RSNs or you miss out on your favorite local teams — it’s that simple. For most of the MLB supporters in the States, Fox’s RSNs used to be the one true service, covering almost all the major teams.

The Bally Sports rebranding has ticked a few people off, but that hasn’t stopped its RSNs from acquiring as many as 14 MLB teams. Take a look at the extensive list of teams below: 

Arizona Diamondbacks on Bally Sports Arizona

Detroit Tigers on Bally Sports Detroit

Miami Marlins on Bally Sports Florida

Cleveland Indians on Bally Sports Great Lakes

Kansas City Royals on Bally Sports Kansas City

St. Louis Cardinals on Bally Sports Midwest

Minnesota Twins on Bally Sports North

Cincinnati Reds on Bally Sports Ohio

San Diego Padres on Bally Sports San Diego

Atlanta Braves on Bally Sports South and Bally Sports Southeast

Texas Rangers on Bally Sports Southwest

Tampa Bay Rays on Bally Sports Sun

Los Angeles Angels on Bally Sports West

Milwaukee Brewers on Bally Sports Wisconsin

Related: Bally Sports App Availability and Release Date

Why can’t you watch your favorite MLB team on Bally Sports?

Bally Sports carries an enviable roster of Major League Baseball teams. Still, if your team isn’t part of the group — which is pretty unlikely — you won’t be able to watch them on Bally Sports. However, having a decorated lineup is only half the story. The next major step is distribution and availability — the two areas where Bally Sports is clearly struggling. Last year, contract talks broke down with YouTube TV, Dish Network, Sling TV, and a couple of other streaming/satellite services, which is bound to take a toll on viewership. So, if you are subscribed to any of the said services, you’re not going to have any luck watching your favorite baseball team.

The Sinclair-led Bally Sports has had trouble coming to terms with the hosting fees that many of the streaming services demanded, and we don’t expect to see the situation improve in the near future. Unless you’re unnaturally loyal to your TV service provider — more than your baseball team — it might be time to consider the alternatives. 

Related: Why Did Fox Sports Change To Bally Sports?

How to watch baseball on Bally Sports

As discussed, you cannot expect the contract talks to improve dramatically overnight, even though there were rumors just before the start of the new baseball season. So, the only option you have is to look for alternatives that carry the channels. And in that case, you pretty much have two options. 

Switch to AT&T TV

AT&T has teamed up with Bally Sports to create the perfect RSN machine in AT&T TV. Since it’s a relatively new player, AT&T could actually use a boost. And giving access to Regional Sports Networks — which no other competitor is delivering — is a pretty neat place to start. As you’d expect, this perk will not come cheap. Bally Sports alongside almost all other major RSNs are available in the Choice and Ultimate packages of AT&T TV. The Choice package will cost you $84.99, which is a whopping $20 hike from YouTube TV’s comparable package. The Ultimate, on the other hand, will set you back $94.99 per month. If you’re really that desperate to watch your local team play in the Major League, you can pick one of the two packages and take comfort in the fact that there’s a 14-day money-back guarantee and no cancellation penalties applicable.

Talk to the local cable operator

Streaming services first emerged as cost-saving solutions to your entertainment needs. They packed cord-cutting convenience and affordability, practically hypnotizing millions of cable users to move over to the other side. However, now with the cost difference evaporating, it’s probably time to welcome cable back into your life. So, before you give up or opt for AT&T, maybe it’s better to have a chat with your local cable operator and see if they can hook you up with a better deal. Additionally, since cable operators are now more than aware of the competition, they are more inclined to offer you better deals. 

Related: What Channel Is Bally Sports on Spectrum?

How to watch MLB if you can’t get Bally Sports

As we’ve discussed, the country’s broadcasting rules forbid you from using third-party means to watch your regional teams. You can only use the RSNs in your area to consume content. However, with the help of VPN services, you can bypass this restriction and cheer your favorite team on — theoretically, at least. 

For those unaware, MLB offers a pretty neat website and a selection of apps that allow you to watch your favorite teams in action, live. The only condition is that you must be viewing out-of-market teams. For example, if you wish to watch Minnesota Twins in action, you must not be in the Bally Sports North region. 

Now, after you get a good VPN service — ExpressVPN, Nord VPN, Surf Shark, and the likes — you can change your region/location to give MLB the impression that you’re from an out-of-market region, even when you’re clearly not. That way, you won’t have to miss a single game of your favorite team, all season long. You can subscribe to MLB TV either for $129.99 or $109.99. The former would grant you access to all teams while the other is single-team only.  


Building Your Android Ui: Everything You Need To Know About Views

What is a View, exactly?


<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent"


//Create a TextView programmatically// TextView tv = new TextView(getApplicationContext()); LayoutParams lp = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); tv.setLayoutParams(lp); tv.setText("Hello World!"); rl.addView(tv); } }

Note that you may be able to declare your app’s default layout in XML, and then modify some of its properties at runtime.

Working with Views: Common XML attributes

When creating a View, you’ll need to define various View properties, using XML attributes. Some of these attributes will be unique to that particular View, but there are a number of XML attributes that you’ll encounter over and over again, regardless of the kind of View you’re working with.

Identifying your Views

Every View must have an integer ID that uniquely identifies that particular View. You define integer IDs in your layout files, for example:



The + symbol signifies that this is a new name that must be created and added to your project’s chúng tôi file.

When you need to work with a View, you can reference it using its View ID. Typically, you’ll reference a View by creating an instance of that View object in your Activity’s onCreate() method, for example:


TextView myTextView = (TextView) findViewById(;

The ID integer technically doesn’t need to be unique throughout the entire tree, just within the part of the tree you’re searching. However, to avoid conflicts and confusion it’s recommended that you use completely unique View IDs, wherever possible.

Layout parameters: Width and height

XML attributes that start with “layout_” define a View’s layout parameters. Android supports a variety of layout parameters, but as a minimum you must define a width and height using the layout_width and layout_height attributes.

Android devices have screens of varying dimensions and pixel densities, so 10 pixels doesn’t translate to the same physical size across every device. If you define a View’s width and height using exact measurements, then this can result in user interfaces that only display and function correctly on devices with specific screens, so you should never use any exact measurements when creating your Views.

Instead, you can define a View’s width and height, using any of the following relative measurements:

wrap_content. This View should be just big enough to display its content, plus any padding.

match_parent. This View should be as big as its parent ViewGroup will allow.

dp. If you need more control over a View’s sizing, then you can provide a density-independent pixel measurement, for example android:layout_width=”50dp.” Note that one dp is roughly equal to one pixel on a “baseline” medium-density screen.

sp. If you want to size text using a density-independent pixel measurement, then you should use scalable pixels (sp), for example: android:textSize=”20sp.” Scalable pixels ensure that your app’s text respects the device’s selected text size, so your text will appear bigger on devices that are set to display Large text, and smaller on devices that are set to display Small text.

Give your content some breathing space!

android:padding. Adds extra space to all four edges. If you define a android:padding value, then it’ll take precedence over any edge-specific values, such as paddingLeft and paddingTop, but it won’t override paddingStart or paddingEnd.

android:paddingBottom. Adds extra space to the bottom edge.

android:paddingEnd. Adds extra space to the end edge.

android:paddingHorizontal. Adds extra space to the left and right edges. If you define a android:paddingHorizontal value then it’ll take precedence over paddingLeft and paddingRight, but not paddingStart or paddingEnd.

android:paddingLeft. Adds extra space to the left edge.

android:paddingRight. Adds extra space to the right edge.

android:paddingStart. Adds extra space to the start edge.

android:paddingTop. Adds extra space to the top edge.

android:paddingVertical. Adds extra space to the top and bottom edges. If you define a android:paddingVertical value, then it’ll take precedence over paddingTop and paddingBottom.

Margins: Adding space around your Views

android:layout_margin. Adds extra space to the left, top, right and bottom sides of a View, for example android:layout_marginRight=”10dp.” If you define a layout_margin value, then it’ll take precedence over any edge-specific values.

android:layout_marginBottom. Adds extra space to the bottom side of the View.

android:layout_marginEnd. Adds extra space to the end side of the View.

android:layout_marginHorizontal. Adds extra space to the left and right sides of the View. Declaring a layout_marginHorizontal value is equivalent to declaring a layout_marginLeft and a layout_marginRight value. A layout_marginHorizontal value will take precedence over any edge-specific values.

android:layout_marginLeft. Adds extra space to the left side of the View.

android:layout_marginRight. Adds extra space to the right side of the View.

android:layout_marginStart. Adds extra space to the start side of the View.

android:layout_marginTop. Adds extra space to the top side of the View.

android:layout_marginVertical. Adds extra space to the top and bottom sides of the View. Declaring a layout_marginVertical value is equivalent to declaring a layout_marginTop and a layout_marginBottom value. A layout_marginVertical value will take precedence over any edge-specific values.

What Android Views can I use?

Now we’ve covered some common layout attributes, let’s take a closer look at some of the Views that are provided as part of the Android SDK.

Displaying text, with TextViews


<TextView android:id="@+id/hello_world" android:layout_height="wrap_content" android:layout_width="wrap_content"


public class MainActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final TextView helloWorldTextView = (TextView) findViewById(; helloWorldTextView.setText(R.string.new_text); } }

You can also style your text, using elements such as android:textColor, android:fontFamily, and android:textStyle, which has possible values of bold, italic, and bolditalic.

EditTexts: Creating editable, interactive text


<EditText android:id="@+id/phoneNumber" android:layout_width="fill_parent" android:layout_height="wrap_content"


android:inputType= Displaying PNGs, JPGs and GIFs


<ImageView android:id="@+id/myImage" android:layout_width="wrap_content" android:layout_height="wrap_content"

In Asset type, select Clip Art.

Select the Clip Art button, which displays the Android logo by default.

Choose any of the Material design icons; I’m using “done.”

Open your project’s drawable folder and you should see a new XML file that defines your chosen Material icon as a vector drawable. Here’s the contents of my vector drawable resource:

android:width="24dp" android:height="24dp" android:viewportWidth="24.0" <path android:fillColor="#FF000000" Buttons and ImageButtons


<Button android:layout_width="wrap_content" android:layout_height="wrap_content"


<ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"

android:drawableLeft. Position the drawable to the left of the text.

android:drawableRight. Position the drawable to the right of the text.

android:drawableStart. Position the drawable to the start of the text.

android:drawableEnd. Position the drawable to the end of the text.

android:drawableTop. Position the drawable above the text.

android:drawableBottom. Position the drawable below the text.

Here, we’re creating a button_icon drawable and placing it at the start of the Button’s button_label text:


<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button_label"


<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button_label"


public void displayToast(View view) { Toast.makeText(MainActivity.this, "Your Message", Toast.LENGTH_LONG).show(); } Give your users options, with CheckBoxes


<CheckBox android:id="@+id/yes" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/yes" boolean checked = ((CheckBox) view).isChecked(); switch(view.getId()) { case if (checked) else Break; case if (checked) Views and ViewGroups: Creating RadioButtons

RadioButtons allow the user to choose from a set of mutually-exclusive options, such as the Agree/Disagree buttons commonly found on Terms and Conditions forms.

android:layout_width="match_parent" android:layout_height="wrap_content" <RadioButton android:id="@+id/radio_confirm" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/confirm" <RadioButton android:id="@+id/radio_deny" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/deny" boolean checked = ((RadioButton) view).isChecked(); switch(view.getId()) { case if (checked) Break; case if (checked) Spinner

A data source that supplies your Spinner with some information; I’ll be using a simple String Array.

An ArrayAdapter that converts your data into View items, ready to be displayed in your Spinner.

<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" <Spinner android:id="@+id/location_spinner" android:layout_width="fill_parent"

Create an ArrayAdapter from the String Array, using the createFromResource() method.

Specify a layout resource that defines how the user’s chosen item should appear in the Spinner. Android provides a simple_spinner_item layout that you should use unless you specifically require a custom layout.

Use setDropDownViewResource(int) to specify which layout the Adapter should use for the Spinner dropdown menu. Once again, Android provides a ready-made layout (simple_spinner_dropdown_item) that should be suitable for most projects.

Apply the Adapter to your Spinner, by calling setAdapter().

Here’s my completed code:


Spinner spinner = (Spinner) findViewById(; R.array.location_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);

The Spinner will receive an onItemSelected event every time the user selects an item from the dropdown. To process this event, you’ll need to use the AdapterView.OnItemSelectedListener interface to define an onItemSelected() callback method.

In the following code, I’m displaying a toast every time onItemSelected() is invoked, and incorporating the name of the newly-selected item into my toast. I’m also defining a onNothingSelected() callback method, as this is also required by the AdapterView.OnItemSelectedListener interface.

Here’s the completed Activity:


import; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.Toast; public class MainActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Spinner spinner = (Spinner) findViewById(; spinner.setOnItemSelectedListener(this); R.array.location_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); } int pos, long id) { Toast.makeText(parent.getContext(), "You've selected n" + parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show(); } @Override } }

You can download this complete project from GitHub.

ListViews: Displaying your data as scrollable lists

android:orientation="vertical" android:layout_width="fill_parent" <ListView android:layout_width="fill_parent" android:layout_height="fill_parent"


import; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.os.Bundle; import android.widget.ListView; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { String[] countryArray = {"Argentina" , "Armenia", "Australia", "Belgium" ,"Brazil" ,"Canada" , "China" , "Denmark" , "Estonia" , "Finland" , "France" , "Greece" , "Hungary" , "Iceland" , "India" , "Indonesia" , "Italy" , "Japan" , "Kenya" , "Latvia"}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listView = (ListView)findViewById(; listView.setAdapter(adapter); @Override Toast.makeText(parent.getContext(), "You've selected n" + parent.getItemAtPosition(position).toString(), Toast.LENGTH_LONG).show(); } } ) ; }}

You can download this completed ListView project from GitHub.

Designing unique experiences: Creating custom Views Wrapping up

Update the detailed information about Safe Mode On Android – All You Need To Know on the website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!