0
I’m getting started in learning about android development.Taking a basic student course. When I got to class on Linearlayout’s things went sideways. The idea is to insert 1 Linearlayout(General) that supports 2 other internal Linearlayout’s.But when inserting components as textview, it is not displayed in the emulation.It is hidden type.
Follow some photos to further unmount the problem:
How it’s supposed to be: Developing: Note: how to observe when inserting the text view components into Layout3 (Viewed layout3). The components are no longer displayed.
XML code:
<?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">
<ImageView
android:id="@+id/imageView"
android:layout_width="80dp"
android:layout_height="50dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/iconetopo" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="16dp"
android:text="TextView"
android:textSize="35sp"
app:layout_constraintStart_toEndOf="@+id/imageView"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/layoutGeral"
android:layout_width="395dp"
android:layout_height="649dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="16dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView">
<LinearLayout
android:id="@+id/layoutDados"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
<EditText
android:id="@+id/editText4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal" />
<TextView
android:id="@+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
<EditText
android:id="@+id/editText5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal" />
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:id="@+id/layoutResusltado"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
The xml of the question was not properly indented, so it did not appear all. It has as main layout a Constraintlayout.
– ramaral
I think the Constraintlayout should be the main one (as the ramaral quoted). Professor Guanabara did so:Image View and text view loose at the top (fixed by the constrainslayout arrows) and then he created the linearLayouts below. "However according to the XML code you passed in the question, your layout is with 3 loose objects an Imageview, a Textview and a Linearlayout." What would be the Linearlayout you said is loose? Is it Layoutgeneral? The app now shows the components.But it’s all on top of each other.
– Ronan
Constraintlayout was not appearing in the question, I will edit the answer.
– Alisson Marqui
It is. I’m sorry. Only now I realized I was missing an excerpt of the code.Thank you for the correction.
– Ronan
@Ronan fixed the response, and updated the example xml, tested it here and it worked.
– Alisson Marqui
@Alissonmarqui, thank you. It helped a lot.I spent a long time beating my head to be able to solve.Now, the app is in compliance and I can continue learning.Thank you very much!!!
– Ronan