Search code examples
javaandroid-toolbar

Title of the app is not appearing on the homescreen


As you can see there is not app title

like in this image

I am very new to Android, and I am learning to make this app with java on android studio.

I'll share more info as per your query.

I tried making an app but couldnt display a app name on the top of the app screen.

this is my main_activity.xml code from the layout

<?xml version="1.0" encoding="utf-8"?>
<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"
    tools:visibility="visible">


    <TextView
        android:id="@+id/Text1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="sans-serif-smallcaps"
        android:text="Enter The Kg Value"
        android:textAlignment="center"
        android:textAppearance="@style/TextAppearance.AppCompat.Large"
        android:textColor="#E91E63"
        android:textSize="28sp"
        android:textStyle="bold"
        app:layout_constraintBottom_toTopOf="@+id/input"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.495"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.772" />

    <EditText
        android:id="@+id/input"
        android:layout_width="wrap_content"
        android:layout_height="48dp"
        android:layout_marginBottom="444dp"
        android:ems="10"
        android:hint="Enter"
        android:inputType="numberDecimal"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.497"
        app:layout_constraintStart_toStartOf="parent" />

    <TextView
        android:id="@+id/Result"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="@font/archivo_black"
        android:textAlignment="center"
        android:textAppearance="@style/TextAppearance.AppCompat.Medium"
        android:textColor="#03A9F4"
        android:textSize="20sp"
        android:textStyle="bold"
        android:typeface="sans"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.498"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/input"
        app:layout_constraintVertical_bias="0.076" />

    <Button
        android:id="@+id/convert"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#8C02B1"
        android:text="Convert"
        app:icon="@android:drawable/stat_notify_sync"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.498"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/Result"
        app:layout_constraintVertical_bias="0.123" />

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="289dp"
        android:layout_height="201dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/convert"
        app:srcCompat="@drawable/kg" />

</androidx.constraintlayout.widget.ConstraintLayout>

Solution

  • There could be a number of reasons why you cannot see the toolbar in your application. Since there is no code shared, I will list some of them:

    1. You have logic in your activity/fragment that hides the Toolbar. Something along like this:

      getSupportActionBar().hide(); //For activity
      
    2. Inside your styles.xml file (under values inside the res folder), you may have something like this:

      <style name="AppTheme.NoActionBar">
         <item name="windowActionBar">false</item>
         <item name="windowNoTitle">true</item>
      </style>
      

    If you have any one of these, just remove them.