Listview Adapter problems with whitespace

Asked

Viewed 83 times

1

I am creating a listview with adpater and I have a problem, I needed to add an image in the middle of the list to stay in the right corner, this image is only an arrow. how can I solve there it occupies all screen space even I set the image size and that is for it to stay in the right corner.

segue XML  lista:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="15dp"
    android:background="@drawable/color_list">



    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:ignore="UselessParent">



        <TextView
            android:text="@string/textview"
            android:layout_width="match_parent"
            android:textSize="18sp"
            android:textStyle="bold"
            android:layout_height="wrap_content"
            android:id="@+id/txtVencimento"
            android:layout_marginLeft="10dp"
            tools:ignore="RtlHardcoded" />



        <TextView
            android:text="TextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/txtPagamento"
            tools:ignore="HardcodedText,RtlHardcoded"
            android:layout_marginLeft="10dp"
            android:elevation="50dp"
            tools:targetApi="lollipop" />

        <TextView
            android:text="TextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/txtNumeDoc"
            tools:ignore="HardcodedText,RtlHardcoded"
            android:layout_marginLeft="10dp"
            android:elevation="50dp"
            tools:targetApi="lollipop" />

        <TextView
            android:text="TextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/txtHistorico"
            tools:ignore="HardcodedText,RtlHardcoded"
            android:layout_marginLeft="10dp"
            android:elevation="50dp"
            tools:targetApi="lollipop" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end"
            app:srcCompat="@drawable/caratrblack"
            android:id="@+id/imageView3"
            tools:ignore="ContentDescription,RtlHardcoded"
            android:layout_marginRight="15dp" />

        <TextView
            android:text="TextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/txtOrigem"
            tools:ignore="HardcodedText,RtlHardcoded"
            android:layout_marginLeft="10dp"
            android:elevation="50dp"
            tools:targetApi="lollipop" />


        <TextView
            android:text="TextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/txtValoresDesconto"
            tools:ignore="HardcodedText,RtlHardcoded"
            android:layout_marginLeft="10dp"
            android:elevation="50dp"
            tools:targetApi="lollipop" />

        <TextView
            android:text="TextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/txtMultaJuros"
            tools:ignore="HardcodedText,RtlHardcoded"
            android:layout_marginLeft="10dp"
            android:elevation="50dp"
            tools:targetApi="lollipop" />

        <TextView
            android:text="TextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/txtTotal"
            tools:ignore="HardcodedText,RtlHardcoded"
            android:layout_marginLeft="10dp"
            android:elevation="50dp"
            tools:targetApi="lollipop" />




    </LinearLayout>

Olhem como ficou esse espaço entre o Histórico e origem, como posso resolver?

</RelativeLayout>

1 answer

1


 <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout
    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:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:ignore="UselessParent">

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

    <TextView
        android:text="teste"
        android:layout_weight="1"
        android:layout_width="wrap_content"
        android:textSize="18sp"
        android:textStyle="bold"
        android:layout_height="wrap_content"
        android:id="@+id/txtVencimento"
        android:layout_marginLeft="10dp"
        tools:ignore="RtlHardcoded" />


    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end"
        app:srcCompat="@drawable/user"
        android:id="@+id/imageView3"
        tools:ignore="ContentDescription,RtlHardcoded"
        android:layout_marginRight="15dp" />

    </LinearLayout>



    <TextView
        android:text="TextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/txtPagamento"
        tools:ignore="HardcodedText,RtlHardcoded"
        android:layout_marginLeft="10dp"
        android:elevation="50dp"
        tools:targetApi="lollipop" />

    <TextView
        android:text="TextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/txtNumeDoc"
        tools:ignore="HardcodedText,RtlHardcoded"
        android:layout_marginLeft="10dp"
        android:elevation="50dp"
        tools:targetApi="lollipop" />

    <TextView
        android:text="TextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/txtHistorico"
        tools:ignore="HardcodedText,RtlHardcoded"
        android:layout_marginLeft="10dp"
        android:elevation="50dp"
        tools:targetApi="lollipop" />

    <TextView
        android:text="TextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/txtOrigem"
        tools:ignore="HardcodedText,RtlHardcoded"
        android:layout_marginLeft="10dp"
        android:elevation="50dp"
        tools:targetApi="lollipop" />


    <TextView
        android:text="TextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/txtValoresDesconto"
        tools:ignore="HardcodedText,RtlHardcoded"
        android:layout_marginLeft="10dp"
        android:elevation="50dp"
        tools:targetApi="lollipop" />

    <TextView
        android:text="TextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/txtMultaJuros"
        tools:ignore="HardcodedText,RtlHardcoded"
        android:layout_marginLeft="10dp"
        android:elevation="50dp"
        tools:targetApi="lollipop" />

    <TextView
        android:text="TextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/txtTotal"
        tools:ignore="HardcodedText,RtlHardcoded"
        android:layout_marginLeft="10dp"
        android:elevation="50dp"
        tools:targetApi="lollipop" />


</LinearLayout>

This should solve your problem. I removed Relative and am using Linearlayout.

You needed to put the image inside another Linear horizontal.

There must be other ways, so I found it easier.

  • I’m sorry, didn’t understand what you said at the end? Only the image is in a horizontal layout?

  • It sits inside a horizontal Linearlayout. standing side by side with the textview

  • That way you can not do here, from Multiple root tags error!

  • Missing xml start. I will edit.

  • 1

    Thanks worked out!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.