Home > front end >  Override LinearLayout
Override LinearLayout

Time:05-31

The item_description is still at the bottom of the arrangement rather than located at the right of item_title.

Any suggestions?

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

    <ImageView
        … />

    <TextView
        android:id="@ id/item_title”
        android:layout_width="150dp"

        …. />
    
    <TextView
        android:id="@ id/item_description”
        app:layout_constraintTop_toTopOf="@id/item_title”
        app:layout_constraintStart_toEndOf="@id/item_title" />

</LinearLayout>

CodePudding user response:

try this :

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

    <ImageView
        … />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal”>
    <TextView
        android:id="@ id/item_title”
    android:layout_width="150dp"

    …. />

    <TextView
        android:id="@ id/item_description”
        app:layout_constraintTop_toTopOf="@id/item_title”
    app:layout_constraintStart_toEndOf="@id/item_title" />
</LinearLayout>
</LinearLayout>

CodePudding user response:

You cannot use Constraints on a Linear Layout only on a ConstraintLayout.

Linear Layout items will always appear in the order you have specified them.

Change the Top level item to ConstraintLayout

  • Related