Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Textview not showing

I have a linearlayout and a textview inside another linearlayout. The linearlayout from inside is displayed, but the problem is that the last textview is not. Why?

    <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:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:padding="10dp"
        android:text="Scrie un cuvant" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center_horizontal"
        android:orientation="horizontal" >

        <EditText
            android:id="@+id/cuvant"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="@string/cuvant_hint"
            android:inputType="text" />

        <Button
            android:id="@+id/cuvantbutton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/cuvantbutton_text" />
    </LinearLayout>


        <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:padding="10dp"
        android:text="Sau random" />
</LinearLayout>

Have a look here,

enter image description here

like image 769
George Irimiciuc Avatar asked Jan 12 '15 12:01

George Irimiciuc


3 Answers

Your LinearLayout has height-attribute fill_parent. Change to wrap_content.

like image 125
Christopher Avatar answered Oct 21 '22 13:10

Christopher


You are actually telling LinearLayout to capture all available space, which is causing you last textview not showing. Instead use "wrap_content" which tells to capture space required to show the available content.

<?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:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:padding="10dp"
        android:text="Scrie un cuvant" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:orientation="horizontal" >

        <EditText
            android:id="@+id/cuvant"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="@string/cuvant_hint"
            android:inputType="text" />

        <Button
            android:id="@+id/cuvantbutton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/cuvantbutton_text" />
    </LinearLayout>

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:padding="10dp"
        android:text="Sau random" />

</LinearLayout>
like image 39
Murtaza Khursheed Hussain Avatar answered Oct 21 '22 13:10

Murtaza Khursheed Hussain


Check the layout_height of internal LinearLayout from match_parent to wrap_content

like image 25
ata Avatar answered Oct 21 '22 11:10

ata