Java 为什么每次Listview都会出现线性布局?

Java 为什么每次Listview都会出现线性布局?,java,android,Java,Android,我正在android studio中创建一个android应用程序。我有一个XML文件songlist.XML。有两种布局,一种是相对布局,另一种是线性布局,两者都位于约束布局内。下面是代码=> <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/androi

我正在android studio中创建一个android应用程序。我有一个XML文件songlist.XML。有两种布局,一种是相对布局,另一种是线性布局,两者都位于约束布局内。下面是代码=>

   <?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:background="#262626"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <RelativeLayout
        android:layout_width="350dp"
        android:layout_height="69dp"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent">

        <TextView
            android:id="@+id/textView"
            android:layout_width="368dp"
            android:layout_height="64dp"
            android:textColor="#ef66dd"
            android:textSize="18dp"
            android:text="TextView"
            android:gravity="center_vertical"
            android:scrollbars="horizontal"
            android:maxLines="1"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            android:layout_marginRight="8dp"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintHorizontal_bias="0.0" />
    </RelativeLayout>

    <LinearLayout
        android:layout_width="333dp"
        android:layout_height="102dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.666"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="1.0"
        tools:layout_editor_absoluteY="409dp">

        <ImageView
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:src="@drawable/default_icon" />
    </LinearLayout>
</android.support.constraint.ConstraintLayout>

正如你所见,线性布局中的图像每次都伴随着一首歌出现。 我想线性布局应该是底部,而不是每次都以这样的歌曲显示:-


我尝试过很多事情,比如创建其他布局,然后在这个布局中包含该布局,但没有成功。如果有人知道问题出在哪里,请告诉我。

有一个描述整个屏幕的布局文件和一个只描述一个列表元素的布局文件。您已将图像放入列表元素的布局文件中,因此图像将按应有的方式为每个列表元素显示。要仅显示一次图像,请将其放入包含您的列表的整个屏幕布局中。

能否请您提供更多详细答案。我不明白:PAnd有两个布局,一个用于列表元素,另一个用于图像。我不知道为什么每次listView重复时图像都会重复
final ArrayList<File> mySongs = findSongs(Environment.getExternalStorageDirectory());
items = new String[mySongs.size()];
for(int i=0; i<mySongs.size(); i++){

    items[i] = mySongs.get(i).getName().toString().replace(".mp3","");

}

ArrayAdapter<String> adp = new ArrayAdapter<String>(getActivity(),R.layout.songllist,R.id.textView, items);
lv.setAdapter(adp);