PeakGen
PeakGen

Reputation: 23005

TextView is not visible

Please have a look at the following code

<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".Game" >

    <TextView
        android:id="@+id/numberOfQuestionsLeft"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="20dp"
        android:text="TextView" />

    <TextView
        android:id="@+id/numberOfCorrectAnswers"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/numberOfQuestionsLeft"
        android:layout_alignBottom="@+id/numberOfQuestionsLeft"
        android:layout_marginLeft="34dp"
        android:layout_toRightOf="@+id/numberOfQuestionsLeft"
        android:text="TextView" />

    <LinearLayout 
        android:id="@+id/linearOne"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="#49494f"
        android:layout_below="@+id/numberOfCorrectAnswers"
        android:paddingTop="20dp"
        >

        <TextView
            android:id="@+id/hint"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginBottom="30dp"
            android:text="Medium Text"
            android:textColor="#ffffff" />

    </LinearLayout>

</RelativeLayout>

This gives the following

enter image description here

As you can see, the hint textview which should appear inside the Linear Layout is not visible. Why is this? Please

Upvotes: 1

Views: 5035

Answers (2)

red_alert
red_alert

Reputation: 1728

You need to do this:

 <LinearLayout 
        android:id="@+id/linearOne"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#49494f"
        android:layout_below="@+id/numberOfCorrectAnswers"
        android:paddingTop="20dp"
        >

        <TextView
            android:id="@+id/hint"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="30dp"
            android:text="MediumText"
            android:textColor="#ffffff" />

    </LinearLayout>

Upvotes: 1

Yakiv Mospan
Yakiv Mospan

Reputation: 8224

Remove android:layout_marginBottom="30dp" from your hint text view :

    <LinearLayout
    android:id="@+id/linearOne"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="#49494f"
    android:layout_below="@+id/numberOfCorrectAnswers"
    android:paddingTop="20dp" >

    <TextView
        android:id="@+id/hint"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:text="Medium Text"
        android:textColor="#ffffff" />

</LinearLayout >

Actually you dont need that Linear Layout, just do like this :

<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:paddingTop="@dimen/activity_vertical_margin"
            tools:context=".Game" >

<TextView
    android:id="@+id/numberOfQuestionsLeft"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="20dp"
    android:text="TextView" />

<TextView
    android:id="@+id/numberOfCorrectAnswers"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/numberOfQuestionsLeft"
    android:layout_alignBottom="@+id/numberOfQuestionsLeft"
    android:layout_marginLeft="34dp"
    android:layout_toRightOf="@+id/numberOfQuestionsLeft"
    android:text="TextView" />


<TextView
    android:id="@+id/hint"
    android:background="#49494f"
    android:paddingTop="20dp"
    android:layout_below="@+id/numberOfCorrectAnswers"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_marginBottom="30dp"
    android:text="Medium Text"
    android:textColor="#ffffff" />

</RelativeLayout >

Upvotes: 1

Related Questions