A
A
amimamoya2021-06-05 15:14:36
Java
amimamoya, 2021-06-05 15:14:36

Items in a ListView are stacked on top of each other. How to fix?

Hello, earlier in the markup for the ListView I used LinearLayout and everything worked fine, but then I needed to replace the regular button with one drawn by me (more precisely, it's just a frame with a transparent background), I did it like this:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/cen"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/back"
    android:orientation="horizontal">

    <ImageView
        android:id="@+id/button2"
        android:layout_width="144dp"
        android:layout_height="52dp"
        android:layout_weight="1"
        android:onClick="vip"
        app:srcCompat="@drawable/ramka" />

    <TextView
        android:id="@+id/data"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView"
        android:layout_marginLeft="40dp"
        android:layout_marginTop="15dp"/>

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginLeft="150dp"
        android:text="TextView" />
</FrameLayout>

The elements are now stacked on top of each other. Tried wrapping this FrameLayout in a LinearLayout but that didn't help.
Are there solutions? Or maybe there is a better way to put images for the button? It's just that among all the methods found on the Internet, I only got this one.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2021-06-05
@amimamoya

This is because your FrameLayout has android:layout_height="match_parent". Its Parent is RecyclerView, its height is taken. Do android:layout_height="wrap_content"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question