TextView does not appear for some reason

0

I would like to do something like this in XML:

I'vetriedwithLinearLayoutbutI'mnotgettingit.

<?xmlversion="1.0" encoding="utf-8"?>
<LinearLayout 
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:background="@color/colorBackground"
   android:orientation="vertical"
   android:weightSum="1" >

<TextView
    android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10px"
    android:layout_marginTop="10px"
    android:fontFamily="serif"
    android:text="Título Legal"
    android:textColor="@color/colorText"
    android:textSize="40px"
    android:textStyle="bold" />

<LinearLayout
    android:layout_width="280px"
    android:layout_height="400px"
    android:background="@drawable/img1"
    android:orientation="horizontal"
    android:weightSum="1">

    <LinearLayout
        android:layout_width="171dp"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Oie"
            android:textColor="@color/colorText"
            android:layout_marginLeft="281px" />

    </LinearLayout>
</LinearLayout>

If I put text where the image is, the text appears, but when I try to put it a bit ahead of the image, it does not appear (android: layout_marginLeft="281px").

Note: The background color is black (@ color / colorBackground) and the color of the text is white (@ color / colorText).

    
asked by anonymous 31.07.2017 / 04:22

1 answer

0

The declaration of the Android libraries in the root of your layout was duplicated and spelled incorrectly. I have already corrected this in the edition of your post.

However, I created a new layout and tested it on my app. It's working just the way you want it:

<?xmlversion="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:id="@+id/layout_group"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent">
        <LinearLayout
            android:id="@+id/layout_left"
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_marginRight="20dp"
            android:gravity="center">
            <ImageView
                android:id="@+id/img1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/icon_alert_error" />
        </LinearLayout>
        <LinearLayout
            android:id="@+id/layout_right"
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1">
            <TextView
                android:id="@+id/text1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Texto 1" />
            <TextView
                android:id="@+id/text1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Texto 2" />
            <TextView
                android:id="@+id/text1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Texto 3" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

The image is in the layout_left and the texts in the layout_right . The layout_group serves to center the two layouts equally on the screen.

    
31.07.2017 / 14:16