Ques. : How to display a normal “Hello World” message in Android using XML code in Linear Layout Views.
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout 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"
    android:contentDescription="@string/app_name"
    android:orientation="vertical"
    tools:context=".MainActivity">


    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        
        android:id="@+id/TxtVwVal"
        android:text="Hello world"      <!-- Hard Coded String message -->
        android:text="@string/msg"      <!-- Soft Coded Real String message -->
        android:justificationMode="inter_word"

        android:textSize="35sp"     <!-- sp means scalable pixel for font size and dp means density pixel for form size, space etc. -->
        android:textStyle="bold"
        android:textColor="@color/red"/>

</LinearLayout>

NB: 
(i) XML comment line is represented by this symbol <!--     --> but appllied for complete block of statements not for partial lines of code.
(ii) Write the XML codes/program for android design development in 'activity_main.xml' file.
(iii) Remove the comment message completely when execute the program.
(iv) Code should be written in activity_main.xml file
Ques. : How to display the message “Hello World” in All Capital Letters in Android using XML code in the Linear Layout View.
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout 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"
    android:contentDescription="@string/app_name"
    android:orientation="vertical"
    tools:context=".MainActivity">


    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        
        android:text="Hello world"
        android:textSize="35sp"
        android:textStyle="bold"
        android:textAllCaps="true"
        android:textColor="@color/design_default_color_on_secondary"/>

</LinearLayout>
Ques. : How to display the Input Text box to take certain input values from users in Android using XML code in the Linear Layout View.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:contentDescription="@string/app_name"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="15"   <!--ems represents the width size of input box as multiple of largest letter M of English alphabets i.e., 15 M size-->

        android:inputType="text"
        android:inputType="number"

        android:hint="Enter your text/numeric value here"
        android:hint="@string/ph"
        />

</LinearLayout>

Loading

Categories: Android

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.