image view and text view side by side in linear layout

0

I have to put the image and the text side by side but I do not know how to do it, my code for now:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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="costamilam.guilherme.contatosempresariais.TelaAjuda">

<ScrollView
    android:id="@+id/sv_help"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:layout_marginBottom="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginTop="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.0">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:weightSum="1">

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="143dp"
            android:layout_height="250dp"
            android:layout_marginTop="15dp"
            android:background="@drawable/shape"
            android:elevation="0dp"
            android:paddingBottom="2dp"
            android:paddingTop="2dp"
            app:srcCompat="@drawable/main_activity"
            android:layout_gravity="left" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="227dp"
            android:layout_height="match_parent"
            android:layout_gravity="right"
            android:layout_weight="0.96"
            android:text="TextView"
            tools:text="@string/tv_introducao" />

    </LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
    
asked by anonymous 20.10.2017 / 02:20

1 answer

2

Change the orientation of LinearLayout to horizontal ( android:orientation="horizontal" ), if you want each item to occupy half of the screen, place android:layout_weight of both with value 1 (sets the weight of each view as I understand it his). If you want to put other views down you can make a LinearLayout vertically and inside it put LinearLayout horizontally

    
20.10.2017 / 02:25