Day32 of #100DaysOfCode

Kushagra Kesav
2 min readMar 10, 2022

--

#CodeTogether Day 32/100

Hii folks 🙌

Today I tried to make one small android app following Unit 2 of Android Basics in Kotlin.

Unit 1: Kotlin basics

Pathway 2: Create your first Android app

Source: https://developer.android.com/courses/android-basics-kotlin/course

Create a Birthday Card app

  • The Layout Editor helps you create the UI for your Android app.
  • Almost everything you see on the screen of your app is a View. Views can be interactive, like a clickable button or an editable input field.
  • A TextView is a UI element for displaying text in your app.
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:fontFamily="sans-serif-light"
android:text="Happy Birthday Sam!"
android:textColor="@android:color/black"
android:textSize="36sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
  • A ConstraintLayout is a container for other UI elements.
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout\_width="match\_parent"
android:layout\_height="match\_parent"
tools:context=".MainActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
  • 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.
  • You can set attributes on a TextView like the font, text size, and color.

Add images to your Android app

  • TheResource Managerin Android Studio helps you add and organize your images and other resources.
  • An ImageView is a UI element for displaying images in your app.
  • ImageViews should have a content description to help make your app more accessible.
<ImageView
android:id="@+id/imageView"
android:layout_width="0dp"
android:layout_height="0dp"
android:importantForAccessibility="no"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/androidparty" />
  • Text that is shown to the user like the birthday greeting should be extracted into a string resource to make it easier to translate your app into other languages.
android:text="@string/happy_birthday_text"

That is all for Day32 ✅

Thanks for reading, See you tomorrow!

--

--