سفارش تبلیغ
صبا ویژن

web development

How to use a gamepad?

    نظر

The world of computer games has become one of the largest worlds in today"s world. Many people around the world spend many hours every day playing these games, and many companies and manufacturers have tried to make it easier for gamers by producing different kind of tools and equipment. Today, technologies are being produced for the game that even thinking about them may cause headaches. The tools that are produced for gaming , in addition to their stunning beauty, are also very useful and can convey a lot of excitement to a gamer. The better and more appropriate the tools used by a gamer, the more fun and excitement a gamer will get from playing. One of the tools used in this field is gamepads. Many players prefer to use different types of mice and keyboards to play instead of using gamepads, but some people also prefer to use different gamepads in addition to having mice and keyboards. Gamepads are used for fixed gaming consoles such as PlayStation and Xbox but are also sold separately.

How to use a gamepad?

What is a gamepad and how can I use a gamepad?  

In addition to knowing that some games can play with both the gamepad and the mouse and keyboard, it is better to know that the gamepads also have many different types. In the first stage of their production, these gamepads had wires, but gradually the manufacturers tried to remove the wire from these devices so that they could multiply the enjoyment of playing for the players. In this way, players can play and enjoy it without disturbing any wires. Gamepads are control panels that allow players to interact with the game environment. The higher the quality of a gamepad, the faster the players" reactions will be transferred to the game, which will make the game better. Also, the gamepads that are produced with the quality have different shocks that convey what happens in the game to the player, the transfer of these emotions causes the great excitement of the game for a player. To use these controllers there are special rules and you need to know the instructions for using them so that you can use them more easily. We are going to talk to you about the specific types of gamepads and how to use a gamepad.

Gamepads for game consoles

These gamepads, as their name suggests, are for game consoles and are

designed for them only. In the past, these controllers were produced in limited numbers and their use was also limited for control, but today, in addition to becoming more beautiful and of better quality, these gamepads have also made other improvements. These gamepads are being designed and produced wirelessly today, and this has improved gaming conditions. Also, different devices can support more than two gamepads, which can increase the spirit of team games and multiply the pleasure of playing. Many of these gamepads have very strong batteries that can hold a charge for many hours. Various consoles such as Xbox and PlayStation design and produce these controllers. There are also more accessories for these categories and game consoles that you can play according to your taste. Note that these gamepads, which are for consoles, have very good quality and it is very exciting to play with them.

Gamepads for Windows

Another type of controller is the Windows gamepads.  Most games designed and produced for Windows can play with the mouse and keyboard, and this is quite a matter of taste that a gamer wants to use the gamepad to play or the mouse and keyboard. Note that also, some games play better with gamepads and others with mice and keyboards.  However, if you, as a gamer, want to buy a gamepad, you should pay attention to the many points that exist in this field. In the first step, you can use two types of wires or wireless. In the wired category, as their name suggests, the gamepad connects with wire to the case of your device, but wireless devices have settings that you must activate before using them. In the settings, you can read the manual that comes with the game controller so that you can easily make these settings on your system.

What is a gamepad and how can I use a gamepad?

Mobile gamepad

Another exciting and interesting kind of gamepad is the phone gamepad. It may be a little surprising to hear this phrase in the first moments, but for mobile games today, different controllers are designed and produced. Because mobile games have a lot of fans today, the manufacturers of game controllers decided to design and produce gamepads for mobile phones to increase the excitement of playing mobile games. Not everyone can afford to buy game systems, so buying a mobile game console can convey a decent amount of excitement to the player, and you can get and use these gamepads at a low cost. These controllers have a lot of power and will multiply the excitement of the game. ‌These gamepads also have different types and can be placed around the frame of your phone or can be placed as a stand under your phone to play and make playing easier for you. You can connect this gamepad directly to your phone so you can use them. Some controllers connect to your phone via Bluetooth, while others connect by wire. However, each type of gamepad that you prepare and use has a special way to connect that you must pay attention to when buying.

Source: https://www.dotnek.com/Blog/Games/how-to-use-a-gamepad

Youtube:https://youtu.be/R842_4dn7qw


What is the best parental control app?

    نظر

Parents have to spend their time worrying about how their children are using the Internet, do they know how to use the Internet properly? And thousands of other questions, all of which make them worried more and more, nowadays, there are so many tools out there that can help you monitor your children easier in order to reduce your worries.

In fact, through these tools, you can monitor all of your children"s activities on the Internet, and if you recognize something suspicious or even when something which is against the law happens, you can warn them and show them the right way, so that they can get away from the problems faster.

Programs can help all parents to keep their children safe online, but you still need to talk to your children about what to look for and the dangers exist in the world of internet which they should get acquainted with, in order to be aware of possible threats, despite all the points mentioned above, there is still a need to use programs that can help you the most, in this article we are going to introduce you to the best software that is available to help parents, through his software , you can find out that when your children are online, when they are offline, what programs they install, and you can even find out when they are alone in the room, and you suddenly enter, whether they exit from the page which was being displayed on their screen or not, the last point can help you find out that whether your children are doing something suspicious or not.

As a parent, you definitely realize that your children are spending more time on the Internet than you do, which is very worrying, if you use these types of software, you will be able to block unwanted web content, limit page time, restrict the use of malicious programs, and so on, but in general, as we have mentioned earlier, it is important to respect your children"s privacy and remind them that you are monitoring their actions on the Internet and tell them that if they use the advantages of the internet and try to make the most of it properly, you will trust them and reduce the control over them.

What is the best parental control app?

What is a parental control app?

A parental control program can track all the activities performed by children, and through these programs, parents can protect their child from cybercriminals, each of the parental control programs provides different facilities for parents, but it is a set of features that are the main features of all control programs, among which we can mention the screen control, program blocker, locator etc., and the program which is able to provide parents with more opportunities, is considered as a better program from their point of view, some of these programs offer features such as call barring to parents that are very welcome by parents, the best parental control programs are mentioned in the following.

The best parental control app:

- Bark:

It is one of the best parental control programs that provides excellent statistics on child control, the way to work with this program is very simple and parents can easily use it to have a control over their children, if a photo or post looks dangerous, Bark immediately notifies parents to take care of their children, you may have set rules for your children that require them to give you their mobile device, tablet, or any other device that is connected to the Internet for a period of time to check whether everything is ok or not, in order to make sure that your children are not at risk, sometimes your children may avoid giving you their devices, in which case such programs will help you, and you can easily monitor your children and give them more guidance if needed.

This company also get help from child psychologists to provide advice to parents in order to be aware of the ways to deal with any scary situation, this application also allows you to set screen restrictions, as well as the feature of web filtering, through this application, parents can monitor social networks, emails, text messages, etc., so if you encounter any suspicious cases, you can take the necessary measures as soon as possible, in addition to this program, there are other applications that are being widely used which are popular among parents today, some of which we are going mention in the following.

Other applications available to help parents:

- mSpy:

One of the applications that help parents a lot every day is mSpy , which have some features including a quick installation process and outstanding customer service, which ultimately allows parents to easily access their child"s device and have control over them.

- Qustodio:

To use this application , you can get help from its free versions, or you may prefer getting more features by paying money, you can use all of its facilities in order to control the activities of your children, one of the features that this program contains and has caused this application to become one of the best applications available for controlling children, is the panic button, it works in a way that if children are in a terrible situation, they can use this button and let you know about their situation, and this application will send the children’s location to the parents eventually, and parents can help their children and save their lives.

This application allows you as a parent to have advanced monitoring of your children on social networks such as Facebook , you can also check calls, text messages, and block suspicious items if you encounter anything through this program, it can be used to control 15 devices at the same time, but it should be noted that the more devices you control with this application, the more you have to pay for it.

This program, like the previous one, has panic button as well as the ability to control the display time of the page, and you can have the opportunity to check the amount of time which your children spend online, another feature of this application is content filtering, which protects your children from many dangers, in a case that some contents may not be suitable for their age range, as a result, this facility is so useful for parents as well as children, plus, there is another important point in parent’s point of view that should be considered, which is the importance of knowing your children’s priorities in life according to the amount of time they spend on social media, if you realize that they prefer spending time on social media instead of doing their homework, you have to keep calm and speak to them kindly, and make them use the Internet properly.

- Net Nanny:

This application also provides many features for parents, but the cost to use this application is higher than the others, which can make many parents avoid using this application, another thing about this program is that launching it, is a bit difficult and time-consuming, but in the end it provides many possibilities for you as parents.

Net Nanny uses real-time scans to keep tabs on new pages and to block them immediately if they are suspicious, like other parental control applications, through this one, you can control the amount of time your children spend on their mobile phone, tablet, etc., and finally teach them time management, tracking your children"s location is another feature that this application can provide for you, which helps you alot while controlling your child.

The best parental control app

Last word:

In general, it is very important for parents to be able to keep their children safe today, and with the development of technology , this task has become more difficult day by day, and parents have resorted to different ways in order to control their children, in this article we have mentioned the best applications available for child control, as well as a number of suitable ones, but in addition to the points mentioned above, there are other applications which help parents have control over their children that all of them have a common goal, which is increasing children safety.

Source: https://www.dotnek.com/Blog/Security/what-is-the-best-parental-control-app

Youtube: https://youtu.be/eRGNWXmZNG8


How to build a Button in Xamarin?

    نظر

Users are more affected by graphical user interfaces because it is both more attractive and saves them from having to go through difficult processes. In other words, graphical user interfaces turn the task of writing complex code into the push of a few buttons. Therefore, buttons play an important and effective role in applications and are used to do things easily. In this part of the tutorial, we will tell you how to create a button in designing and building applications .

How to build a Button in Xamarin?

What is a Button?

Button Reject GUI design field is any type of widget that is provided to users to perform events in a simple way. Buttons are also called command buttons because they perform user commands for certain events.

For example, pressing the Save button in some of the notifications that appear will save the files in a specified path. Or OK can be used to confirm the contents or close some windows.

Buttons are usually or often in the form of rectangles that are smaller in width than length and are used to perform user commands in a simple way. According to the text that is written on the button, users can identify the operation that each button performs and select and click the appropriate button to do their work based on their needs. Therefore, there may be several buttons in a window and each of them is used to do different things, users can understand the meaning according to the text written on each button and press the appropriate button.

The text that is written on each button is called Caption. When inserting a caption, be careful to write it related to the type of activity that the button performs.

Buttons can have different modes, and the user can do the following methods to perform the desired operation through the buttons:

- They can click on the available buttons.
- On touch screens, touch the buttons.
- If the buttons are in focus mode, press the Enter or Space bar arrow keys.
- Use shortcuts. This is the case when shortcuts are defined for buttons.

In this tutorial you will learn:

- How to create a Button in Xamarin.Forms using the XAML file?
- How to respond to the pressing of buttons?
- How to change the appearance of Button and create a graphical user interface for it?

Learn how to create a Button in Xamarin.Forms using Visual Studio

The requirements for doing this training are as follows:

- Install the latest version of Visual Studio 2019 on the system
- Install the latest version of Mobile development with .NET on the system

1- Open Visual Studio.
2- After opening Visual Studio, you must create a new black Xamarin.Forms app.
3- Choose a name for which you create. The name chosen in this article is Button Tutorial.

Note:

It is best to be careful in choosing names for projects and classes created.

Note:

The name selected for the project must be the same as the name chosen for the solution, so select the solution name ButtonTutorial as well.

-  After naming, you must make sure that the system and application support the .NET Standard mechanism for shared code.

This mechanism is used to share code written in Xamarin.Forms with the C # programming language. If your system and app do not support this mechanism, it cannot have multiple outputs on multiple platforms at once. So that you can have multiple outputs on several different platforms at the same time.

- Click on MainPage.xaml in the Solution Explorer section of the ButtonTutorial project and replace the code below with all the code in that section.

<! -? xml version = "1.0" encoding = "utf-8"? ->

<contentpage xmlns = "http://xamarin.com/schemas/2014/forms" xmlns: x = "http://schemas.microsoft.com/winfx/2009/xaml" x: class = "ButtonTutorial.MainPage">

<stacklayout margin = "20,35,20,20">

<button text = "Click me">





</button></stacklayout> </contentpage>

By entering this code, you specify a UI for the application, which includes a Button in StackLayout. Button.Text to display the key text that will be displayed on the button.

- Press the Start button or Ctrl + F5 key combination to see the result of the applied changes.

If you look closely, you will see that the Button occupies all the space on the screen.

Learn to respond to Button in Xamarin.Forms using Visual Studio

1- To respond to Button, you must change the Button definition in the MainPage.xaml file.
2- To do this, you must enter the code to create a handler for the Clicked event.

Replace the code below with all the code in the MainPage.xaml file.

    <button text = "Click me" clicked = "OnButtonClicked">
</button>

By entering this code, you can set the Clicked event to event handler. The name of the event handler is OnButtonClicked.

3- Click on MainPage.xaml in the Solution Explorer section of the ButtonTutorial project.

4- Then double click on MainPage.xaml.cs to open it.

5- Add the OnButtonClicked event handler to the class by entering the following code.

void OnButtonClicked (object sender, EventArgs e)

{

(sender as Button). Text = "Click me again!";

}

The OnButtonClicked method is executed when the Button is pressed. The sender argument starts the Clicked event.

In addition to the Clicked event, there are other events such as Pressed and Released.

- Press the Start button or Ctrl + F5 key combination to see the result of the applied changes. In this case, you will notice the text change inside the button.

Learn how to change the appearance of Button in Xamarin.Forms using Visual Studio

1- In order to change the appearance of Button and create an attractive graphical user interface for it, you have to change the definition of Button in the MainPage.xaml file.
2- To do this, open MainPage.xaml and replace the code listed below with the code there.

    <button text = "Click me" clicked = "OnButtonClicked" textcolor = "Blue" backgroundcolor = "Aqua" bordercolor = "Red" borderwidth = "5" cornerradius = "5" widthrequest = "150" heightrequest = "75">
</button>

By entering this code, you change the appearance of Button. The TextColor attribute is an attribute used to change or specify the color of a button. With the values ??you put in this attribute, you specify the color of the button.

The shape of the button is rectangular by default, which is less than its width, but the values ??in the CornerRadius attribute can soften the corners and turn it into other shapes, such as circles. Of course, to change the shape of the button, you can specify and change the values ??of WidthRequest and HeightRequest by decreasing or increasing the values.

The BackgroundColor attribute is used to change the background color of the button text. The values ??in the BorderColor attribute can specify the color of the perimeter around the button.

The BorderWidth attribute specifies the width of the button border, the higher the value of this attribute, the thicker the border, and the smaller the value of this attribute, the narrower the border.

- Press the Start button or Ctrl + F5 key combination to see the result of the applied changes. In this case, you will notice that the appearance of the button has changed and has been adjusted according to the changes you have made.

Learn how to create a Button in Xamarin.Forms using Visual Studio for Mac

The requirements for doing this training are as follows:

- Install the latest version of Visual Studio for Mac on the system
- Install the latest version of support platform for Android and iOS on the system
- Install the latest version of Xcode

1- Open Visual Studio.
2- After opening Visual Studio, you need to create a new black Xamarin.Forms app 3- Select the name for which you are creating. The name chosen in this article is ButtonTutorial.

Note:

It is best to be careful in choosing names for projects and classes created.

Note:

The name selected for the project must be the same as the name chosen for the solution, so select the solution name ButtonTutorial as well.

- After naming, you must make sure that the system and application support the .NET Standard mechanism for shared code.

This mechanism is used to share code written in Xamarin.Forms with the C # programming language. If your system and app do not support this mechanism, it cannot have multiple outputs on multiple platforms at once. So that you can have multiple outputs on several different platforms at the same time.

- Click on MainPage.xaml in the Solution Pad section of the ButtonTutorial project and replace the code below with all the code in that section.

<! -? xml version = "1.0" encoding = "utf-8"? ->

<contentpage xmlns = "http://xamarin.com/schemas/2014/forms" xmlns: x = "http://schemas.microsoft.com/winfx/2009/xaml" x: class = "ButtonTutorial.MainPage">

<stacklayout margin = "20,35,20,20">

<button text = "Click me">





</button></stacklayout> </contentpage>

By entering this code, you specify a UI for the application, which includes a Button in StackLayout. Button.Text to display the key text that will be displayed on the button.

- Press the Start button or Ctrl + F5 key combination to see the result of the applied changes.

If you look closely, you will see that the Button occupies all the space on the screen.

Learn how to respond to Button in Xamarin.Forms using Visual Studio for Mac

1- To respond to Button, you must change the Button definition in the MainPage.xaml file.
2- To do this, you must enter the code to create a handler for the Clicked event.

Replace the code below with all the code in the MainPage.xaml file.

<button text = "Click me" clicked = "OnButtonClicked">

</button>

By entering this code, you can set the Clicked event to event handler. The name of the event handler is OnButtonClicked.

1- Click on MainPage.xaml in the Solution Pad section of the ButtonTutorial project.
2- Then double click on MainPage.xaml.cs to open it.
3- Add the OnButtonClicked event handler to the class by entering the following code.

void OnButtonClicked (object sender, EventArgs e)

{

(sender as Button). Text = "Click me again!";

}

The OnButtonClicked method is executed when the Button is pressed. The sender argument starts Clicked event on Clicked event, there are other events like Pressed and Released.

- Press the Start button or Ctrl + F5 key combination to see the result of the applied changes. In this case, you will notice the text change inside the button.

What is a Button?

Learn how to change the appearance of Button in Xamarin.Forms using Visual Studio for Mac

1- To change the appearance of the Button and create an attractive graphical user interface for it, you must change the Button definition in the MainPage.xaml file.
2- To do this, open MainPage.xaml and replace the code below with the code below.

    <button text = "Click me" clicked = "OnButtonClicked" textcolor = "Blue" backgroundcolor = "Aqua" bordercolor = "Red" borderwidth = "5" cornerradius = "5" widthrequest = "150" heightrequest = "75">
</button>

By entering this code, you change the appearance of Button. The TextColor attribute is an attribute used to change or specify the color of a button. With the values ??you put in this attribute, you specify the color of the button.

The shape of the decanter is rectangular by default, which is less than its length, but the values ??in the CornerRadius attribute can soften the corners and turn it into other shapes, such as a circle. Of course, to change the shape of the button, you can specify and change the values ??of WidthRequest and HeightRequest by decreasing or increasing the values.

The BackgroundColor attribute is used to change the background color of the button text. The values ??in the BorderColor attribute can specify the color of the perimeter around the button.

The BorderWidth attribute specifies the width of the button border, the higher the value of this attribute, the thicker the border, and the smaller the value of this attribute, the narrower the border.

- Press the Start button or Ctrl + F5 key combination to see the result of the applied changes. In this case, you will notice that the appearance of the button has changed and has been adjusted according to the changes you have made.

Source: https://www.dotnek.com/Blog/Apps/how-to-build-a-button-in-xamarin

 


Top 11 Adventure games on google play and Apple app store

    نظر
Top 11 Adventure games on google play and Apple app store

Top 11 Adventure games

Adventure games are one of the parts of computer games that have a lot of fans. These games have usually very high quality due to their special programming and have the ability to keep their audience entertained for many hours. We are going to talk to you about some exciting games. If you are also curious to know and recognize these games and use them, follow us to the end. In general, the style of this games can be easily run on mobile phones, and its ability to run on mobile phones has led developers to produce more games in this style. These games are story-driven and in addition to being exciting, they are also very attractive.

1. This war of mine

This game was designed and produced in 2015 and many people from that time, became interested in playing this game. This game is so interesting that from 2015 until now, its fans have not only not decreased, but it is increasing day by day. In this game, you have to try to save your life and the decisions you make during the game are very important and vital, and wrong decisions may lead to the death of certain people. This game requires a lot of attention.

2. Telltale Games

These games are available on the Google Play Store and you have to pay to play them.  Note that these games are very popular and are usually based on attractive foreign series.  If you are interested in these series, you can also enjoy playing with their games.

3. Shadow gun

Another adventure game is this game, which has an action and shooting style in the category of Android games, but it is also adventurous. This game has a science-fiction genre and is very rich and spectacular in terms of graphics and environment. In this game, while you are browsing, you have to solve various puzzles to get points.

4. To the moon

This game has a very interesting and exciting story and the storyline in this story is very important and vital. The game was first released for Android and iOS in 2017, but earlier in 2011 the game was released for the PC. One of the important features of this game is its fascinating story. You will play with two characters in this game.  This game feels good with it and is categorized as a relaxing game.

5. The Talos principle

This game is one of the most popular and exciting games that has attracted the attention of many critics and users.  Note that the mobile version of this game, just like the console and computer version of this game, has extraordinary movement mechanisms, and you can run it easily and without any problems on your mobile phone.

6. To be or not to be

Another exciting game that falls into the category of adventure kind of games is this game. In this game, you will play the lead role in many of Shakespeare"s plays and stories, and you will make out the story with your own hands.

7. Out there

Another game is this game that will have a great experience for players. In this game, you have to play the role of an astronaut who has come to his senses on an alien planet and intends to try to survive. In this game, you have to try to travel to different planets and establish friendly relations with the creatures that live on these planets, and convince them to help you. In this game, you have to repair your spaceship and try to get closer to your planet Earth. This game is a very exciting and suitable game for people who are interested in space stories.

8. Limbo

Another Android game is this game, which is one of the best adventure kind games from 2016 until today. In addition to being the best adventure game, this game is also very popular in other fields and has attracted a lot of people. The game environment is uniquely designed and is very attractive and enjoyable even in two-dimensional mode. It conveys excitement and well to the player.

9. Lara Croft Go

This game another exciting adventure game that is designed and produced in an enigmatic and adventurous style. This game has different series and the Lara Croft Go version is another extremely attractive version of this game. In this game, you have to solve various puzzles and use your intelligence well.

10. Pokémon Go

This game is one of the most diverse and popular mobile games that has been able to attract the attention of many people in recent years. The creators of this game were able to use real features according to their intelligence and creativity to be able to design and produce a challenging and exciting game. In this game, you have to look for Pokémon and collect them. This game had a lot of fans when it was released and attracted a lot of people, but you may have heard some sad news about the various events of the game"s players, but still, this game brings a lot of excitement with it.

Top 11 Adventure games

11. Frostrune

Another exciting game that falls into the category of adventure games is Frostrune. This game has a mythical and historical theme and is very exciting and different. If you are interested in the gods of Rome and Greece, this game can be a suitable option for you. This game is completely mysterious and is based on strange and challenging puzzles that you must solve to complete the steps of this game.

Source: https://www.dotnek.com/Blog/Games/top-11-adventure-games-on-google-play-and-app

Youtube: https://youtu.be/TixbWeOM0mA


Different types of font resources in Xamarin and how to use them

    نظر

In order for the operating system to support these fonts and show exactly what is in the application , it is necessary to apply special settings to support the fonts in the application. In this tutorial, we will teach you how to apply settings to the operating system to support application fonts. If you want to know about them, follow this tutorial.

Different types of font resources in Xamarin and how to use them

The ways to use fonts in operating systems and applications are as follows:

1- One way to use fonts and display them is to package all fonts as the source of Android 2- and put them in the application and operating system. In this case, it is clear that all fonts are always present in the Android operating system, and when needed, you can refer to its source. Packing fonts and placing them on the Android source allows us to access the fonts at all times.

3- The second way to use fonts is to download fonts. In this case, the Android operating system also supports the download of fonts, so that if necessary, we download the relevant font and save it inside the Android operating system. Fonts are downloaded by the font provider and the font provider checks to see if the corresponding font is present within the operating system. If there is no relevant font, the font provider will download it and save it inside the Android operating system.

It should be noted that all fonts that are similar or similar and have the same style are classified in one group. Fonts that have the same style and are similar to each other are grouped into groups such as font families. Users must consider unique specifications in order to use these similar fonts. In this way, they can choose their unique names or specify their characteristics. Android Support Library v26 uses API level 26 to support and use fonts. If we consider APIs whose level is less than 26, then we have to specify android: namespace and app: namespace for them. If we do not specify android: namespace and app : namespace for them and consider only android: namespace, they may not be displayed on lower than 26 operating systems. So in order for all fonts to be displayed with an API level less than 26, both android: namespace and app: namespace must be specified, otherwise if not specified, both fonts will not be displayed. APIs with a level below 26 do not support fonts and must be set to android: namespace and app: namespace in order to be displayed.

The code snippets below are used to display the font family in API level 14 and above.

<? xml version = "1.0" encoding = "utf-8"? >
<font-family
xmlns: android = "http://schemas.android.com/apk/res/android"
xmlns: app = "http://schemas.android.com/apk/res-auto">
<font android: font = "@ font / sourcesanspro_regular"
android: fontStyle = "normal"
android: fontWeight = "400"
app: font = "@ font / sourcesanspro_regular"
app: fontStyle = "normal"
app: fontWeight = "400" />
</ font-family>

To display different types of fonts in TextView, you need to make the appropriate settings. For example, the following code snippet describes how to display different types of fonts in TextView.

< TextView
android: text = "The quick brown fox jumped over the lazy dog."
android: fontFamily = "@ font / caveat_bold"
app: fontFamily = "@ font / caveat_bold"
android: textAppearance = "? android: attr / textAppearanceLarge"
android: layout_width = "match_parent"
android: layout_height = "wrap_content" />

Source of Font Package in Android

If the fonts are in the form of Packages, it means that the fonts are guaranteed to be inside the operating system and can always be used. Font files in TTF or TOF format like other programs are added to Xamarin. Android and stored in the operating system. The font files are located in the Resources folder of the Xamarin.Android project.

Note:

Fonts must have Built Action from AndroidResource.

Fonts in a family and group

Fonts that have the same style and are similar to each other are placed in a group called Font Families. The font family is saved with the font elements in the XML file. The XML file is also stored in the Resources / font path.

Each font family must have its own XML file to be saved with its fonts and elements. If you want to create a font family, you must add all the fonts to the Resources / font folder. Then create an XML file inside the created font folder.

The XML file creates a font family below and stores them in the Resources / font folder named sourcesanspro.xml.

<? xml version = "1.0" encoding = "utf-8"? >
<font-family xmlns: android = "http://schemas.android.com/apk/res/android"
xmlns: app = "http://schemas.android.com/apk/res-auto">
<font android: font = "@ font / sourcesanspro_regular"
android: fontStyle = "normal"
android: fontWeight = "400"
app: font = "@ font / sourcesanspro_"
app: fontStyle = "normal"
app: fontWeight = "400" />
<font android: font = "@ font / sourcesanspro_bold"
android: fontStyle = "normal"
android: fontWeight = "800"
app: font = "@ font / sourcesanspro_bold"
app: fontStyle = "normal"
app: fontWeight = "800" />
<font android: font = "@ font / sourcesanspro_italic"
android: fontStyle = "italic"
android: fontWeight = "400"
app: font = "@ font / sourcesanspro_italic"
app: fontStyle = "italic"
app: fontWeight = "400" />
</ font-family>

Three different values ??can be given for the fontStyle attribute:

- normal

- Italic

- bold

The fontWeight feature is used to specify the font thickness and can take different values:

- Thin - 100

- Extra Light - 200

- Light - 300

- Normal - 400

- Medium - 500

- Semi Bold - 600

- Bold - 700

- Extra Bold - 800

- Black - 900

The code snippet below defines a family of fonts with Italic text style features and a thickness of 400:

<TextView
android: text = "Sans Source Pro semi-bold italic, 600 weight, italic"
android: layout_width = "match_parent"
android: layout_height = "wrap_content"
android: fontFamily = "@ font / sourcesanspro"
android: textAppearance = "? android: attr / textAppearanceLarge"
android: gravity = "center_horizontal"
android: fontWeight = "600"
android: textStyle = "italic"
/>

Provide custom font settings with programming

The code below shows how programming can be used to display fonts inside TextView:

Android.Graphics. Typeface = this. Resources.GetFont (Resource.Font. caveat_regular);
textView1.Typeface = typeface;
textView1.Text = "Changed the font";

If you use the GetFont method, it automatically selects the first font in the font family inside the folder, but if you want to choose a font with special features, you can use the Typeface.Create method. This method provides you with the fonts you want.

Selects the code below the font whose Typeface is bold for display in TextView.

var typeface = Typeface.Create ("<FONT FAMILY NAME>", Android.Graphics. TypefaceStyle.Bold);
textView1.Typeface = typeface;

Download fonts

Instead of using packaged fonts and storing them inside the operating system, you can download the fonts and temporarily save the audio inside the operating system or application . In this case, you also reduce the size of the APK. If you use packaged fonts, the size of the APK will increase, but if you download the fonts from various sources and temporarily store them in applications and operating systems, their size will decrease.

Fonts are downloaded from various sources by the font provider. Android operating system with version 8.0 has a font provider for downloading fonts from various sources that download fonts from this version from Google Font Repository.

How the font provider works is that after requesting a program or application for a font with special features and specifications, the font provider checks whether there are fonts with the same features and specifications in the system. If there is no font with the same features and specifications, the font provider tries to download the font from different sources and submit it to the program and application. After downloading the font from a source, in addition to the program and application request Other programs and applications can also use the downloaded font, although it should be noted that applications do not request the font directly from the font provider, but applications and applications will use the FontsContract API.

How to support Android operating system with version 8.0 of downloading fonts from various sources:

1- Announcing downloadable fonts for the Android operating system as a source: In this case, the program announces the downloadable fonts as XML resource files. Android saves these fonts on the system after downloading and integrating them.

Programming:

A FontRequest is considered for each font and FontRequest is sent to the FontsContract class. FontsContract actually takes FontRequest and then receives the desired font from the font provider.

2- resources files must be added to the Xamarin.Android project and application before the fonts are downloaded. First, the fonts are placed inside the XML file in the Resources / font folder.

The code below shows how to download the fonts in full:

<? xml version = "1.0" encoding = "utf-8"? >
<font-family xmlns: android = "http://schemas.android.com/apk/res/android"
xmlns: app = "http://schemas.android.com/apk/res-auto"
android: fontProviderAuthority = "com.google.android.gms. fonts"
android: fontProviderPackage = "com.google.android.gms"
android: fontProviderQuery = "VT323"
android: fontProviderCerts = "@ array / com_google_android_gms_fonts_certs"
app: fontProviderAuthority = "com.google.android.gms. fonts"
app: fontProviderPackage = "com.google.android.gms"
app: fontProviderQuery = "VT323"
app: fontProviderCerts = "@ array / com_google_android_gms_fonts_certs"
>
</ font-family>

The information that Android needs to receive and download fonts is as follows:

fontProviderAuthority:

Allows the Font Provider to check and use the request.

fontQuery:

is actually a string that helps the font provider to find the desired font.

fontProviderCerts:

is a resource presentation.

Font Certificates

If the font provider is not already installed on the device, the Android operating system will need some font provider security certificates. These certificates are stored inside the resource array file in the Resources / values ??directory and path.

For example, the code below is an XML file that stores Google font provider certificates.

<? xml version = "1.0" encoding = "utf-8"? >
<resources>
<array name = "com_google_android_gms_fonts_certs">
<item> @ array / com_google_android_gms_fonts_certs_dev </ item>
<item> @ array / com_google_android_gms_fonts_certs_prod </ item>
</ array>
<string-array name = "com_google_android_gms_fonts_certs_dev">
<item>

</ item>
</ string-array>
<string-array name = "com_google_android_gms_fonts_certs_prod">
<item>
</ item>
</ string-array>
</ resources>
Despite these source files, fonts can be downloaded and used.
Declare downloadable fonts as the source of the fonts
If we list the downloadable fonts inside the AndroidManifest.XML file, Android will start downloading them asynchronously.
<? xml version = "1.0" encoding = "utf-8"? >
<resources>
<array name = "downloadable_fonts" translatable = "false">
<item> @ font / vt323 </ item>
</ array>
</ resources>

After these codes, the following code must be added to them:

<meta-data android: name = "downloadable_fonts" android: resource= "@ array / downloadable_fonts" />

Download fonts using the Font API for use in applications installed on the Android operating system

If you use the FontContractCompat.RequestFont method to download fonts, this method will first check if the requested font is present within the system itself. If the desired font is not inside the system, the font provider will start searching for that font from various sources and finally download it and use it inside the application and system. FontRequest is the same request that is sent to the font provider and requests the download of the font with the desired specifications.

If the desired font does not exist inside the system and the font provider cannot download it, then the default font of the Android operating system will be used.

Different types of font resources in Xamarin

FontRequest has four sections:

Font Provider Authority: This part of FontRequest allows the Font Provider to use the request and the Font Provider downloads the desired font and places it in the system according to the request.

Package:

Font Provider is used to authenticate and actually allows it to use the request.

fontQuery:

This section is a string that contains details and information about fonts.

fontProviderCerts:

This section is also a resource presentation.

The following code describes FontRequest simulation:

FontRequest request = new FontRequest ("com.google.android.gms. fonts", "com.google.android.gms", <FontToDownload>, Resource.Array.com_google_android_gms_fonts_certs);

The code below also indirectly downloads the font from the Google Fonts Open Source collection.

public class FontDownloadHelper: FontsContractCompat.FontRequestCallback
{
// A very simple font query; replace as necessary
public static readonly String FontToDownload = "Courgette";

Android.OS. Handler = null;

public event EventHandler <FontDownloadEventArg> FontDownloaded = delegate
{
// just an empty delegate to avoid null reference exceptions.
};


public void DownloadFonts (Context context)
{
FontRequest request = new FontRequest ("com.google.android.gms. fonts", "com.google.android.gms", FontToDownload, Resource.Array.com_google_android_gms_fonts_certs);
FontsContractCompat.RequestFont (context, request, this, GetHandlerThreadHandler ());
}

public override void OnTypefaceRequestFailed (int reason)
{
base. OnTypefaceRequestFailed (reason);
FontDownloaded (this, new FontDownloadEventArg (null));
}

public override void OnTypefaceRetrieved (Android.Graphics. Typeface typeface)
{
base. OnTypefaceRetrieved (typeface);
FontDownloaded (this, new FontDownloadEventArg (typeface));
}

Handler GetHandlerThreadHandler ()
{
if (Handler == null)
{
HandlerThread = new HandlerThread ("fonts");
handlerThread.Start ();
Handler = new Handler (handlerThread.Looper);
}
return Handler;
}
}


/// <summary>
/// EventArg when a font has been downloaded.
/// </ summary>
public class FontDownloadEventArg: EventArgs
{
public FontDownloadEventArg (Android.Graphics. Typeface typeface)
{
Typeface = typeface;
}
public Android.Graphics. Typeface {get; private set;}
public bool RequestFailed
{
get
{
return Typeface! = null;
}
}
}
The code below also creates a FontDownloadHelper that will guide and assist you in the font download process.
var fontHelper = new FontDownloadHelper ();

fontHelper.FontDownloaded + = (object sender, FontDownloadEventArg e) =>
{
// React to the request
};
fontHelper.DownloadFonts (this); // this is an Android Context instance.

In this tutorial, you will get acquainted with the APIs used in version 8.0 of Android. How to place fonts inside the APK and use and display them in the layout in this tutorial, was taught. You can apply special settings using the codes included in this tutorial and you can use different fonts by using two methods of programming and downloading fonts.

Source: https://www.dotnek.com/Blog/Apps/different-types-of-font-resources-in-xamarin