Config
- Android Virtual Device (AVD) manager : Used to create an emulator. You will find it in
Tools > AVD Manager
Layouts
TextView
- Each of the elements on screen is called View
The Views in an Android app don’t just float on the screen by themselves. Views have relationships to each other. For example, an image may be next to some text, and buttons may form a row. To organize Views, you put them in a container. A ViewGroup is a container that View objects can sit in, and is responsible for arranging the Views inside it. The arrangement, or layout, can change depending on the size and aspect ratio of the screen of the Android device that the app is running on, and the layout can adapt to whether the device is in portrait or landscape mode. - Android Documentation
- ConstraintLayout is a ViewGroup which helps you arrange the Views inside it in a flexible way.
- Layout Editor
- Views need to be constrained horizontally and vertically within a ConstraintLayout.
- One way to position a View is with a margin
- A margin says how far a View is from an edge of the container it’s in.
- Eg: While positioning the text view, margin is the distance from the TextView to the edge of the container, the ConstraintLayout
- The unit for margins and other distances in the UI is density-independent pixels (dp)
Note: Just like dp is a unit of measure for distances on the screen, sp is a unit of measure for the font size. UI elements in Android apps use two different units of measurement, density-independent pixels (dp) which you used earlier for the layout, and scalable pixels (sp) which is used when setting the size of text. By default,sp is the same size as dp, but it resizes based on the user’s preferred text size. - Android documentation
- You can set attributes on a TextView like the font, text size, and color.
ImageView
- An ImageView is a UI element for displaying images in your app.
Importing images in android studio.
- In Android Studio, click on View > Tool Windows > Resource Manager in the menus or click on the Resource Manager tab to the left of the Project window.
- Click the + below Resource Manager, and select Import Drawables. This opens a file browser.
- In the file browser find the image file you downloaded and click Open.
- Click Next. Android Studio shows you a preview of the image.
- Click Import.
- If the image has been imported successfully, Android Studio adds the image to your Drawable list.
- Go to Project View of your app. Confirm the image is in the drawable folder by expanding app > res > drawable.
Note: Note: A constraint in the context of the Layout Editor represents a connection or alignment of a view to another view, the parent layout, or an invisible guideline. For example, a view can be constrained to be a certain distance from the edge of its container, or always be to the right of another view, or always the top view inside a container. - Android documentation
Size and align the image on screen using ScaleType
Order of the views matters most on ther screen
Translating
When you write apps, it’s important to remember that they may be translated into another language at some point. A hardcoded string is one that is written directly in the code of your app. Hardcoded strings make it more difficult to translate your app into other languages, and harder to reuse a string in different places in your app. You can deal with those issues by “extracting strings into a resource file” . That means instead of hardcoding the string in your code, you put the string into a file, give it a name, and then use the name whenever you want to use this string. The name will stay the same, even if you change the string or translate it to a different language.
Your extracted strings are stored in (app > res > values > strings.xml). The strings.xml file has a list of strings that the user will see in your app. Note that the name of your app is also a string resource. By putting the strings all in one place, you can more easily translate all the text in your app, and more easily reuse a string in different parts of your app.
Accessibility
Note: Android provides many tools for users. For example, TalkBack is the Google screen reader included on Android devices. TalkBack gives users spoken feedback so that users can use their device without looking at the screen. Read more about accessibility in the developer reference guide. - Android documentation
- A content description can help make your app more usable with TalkBack by defining the purpose of the UI element.
- If you want to skip a view from accessibility set
importantForAccessibility
attribute tono
For more info Refer :