abhiman Su
abhiman Su

Reputation: 9

how to hiding the textview text

In layout, TextView would be created but behind the TextView there should be some words are behind. How should I identify?

This is android studio latest version

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:id="@+id/roomnum"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="2dp"
        android:textColor="@color/colorBlack"
        android:textSize="@dimen/activity_title" />

    <TextView
        android:id="@+id/roomtype"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="2dp"
        android:textColor="@color/color_graylight"
        android:textSize="@dimen/activity_title" />

</LinearLayout>

I want behind the words.

Upvotes: 0

Views: 78

Answers (3)

Quacking Kahuna
Quacking Kahuna

Reputation: 73

I have a strange feeling that your question is asking about a hint. For example: You have a TextView and expected input is some room in a house. So the TextView will show something like "Room name", it will be in the color of light gray. If somebody types into the TextView text color will be black with his input. Am I right?

EDIT: After your comment I am sure you are talking about Hint. There is no reson for hint in TextView it is used in EditText to let user know what is the expected input there.

<EditText
        android:id="@+id/text_New_Name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:ems="10"
        android:hint="HERE IS YOUR HINT"
        android:inputType="textPersonName"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

Upvotes: 0

bijaykumarpun
bijaykumarpun

Reputation: 707

Use RelativeLayout to place two texts on top of each other. Then toggle their visibility accordingly. For example when button is clicked:

textViewFirst.setVisibility(View.INVISIBLE)
textViewSecond.setVisibility(View.VISIBLE)

Upvotes: 1

No Name
No Name

Reputation: 470

Seems the question is not very clear. I have sample code here that can help you.

<android.support.constraint.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">

    <!--<RelativeLayout-->
        <!--android:layout_width="wrap_content"-->
        <!--android:layout_height="wrap_content">-->
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="A"
        android:textSize="20sp"
        android:textColor="#000"
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="SAMPLE TWO"
        android:textSize="10sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    <!--</RelativeLayout>-->

</android.support.constraint.ConstraintLayout>

Sample screenshot

enter image description here

Upvotes: 0

Related Questions