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,
Your LinearLayout
has height-attribute fill_parent
. Change to wrap_content
.
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>
Check the layout_height
of internal LinearLayout
from match_parent
to wrap_content
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With