0
我有一個listView裏面的一個自定義ArrayAdapter呈現的MainActivity的片段。問題是由於某種原因,listview無法滾動。Android ListView在片段不滾動
我的XML MainActivity:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:design="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:screenOrientation="portrait"
tools:context=".MainActivity">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#f1f1f1">
</FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
design:menu="@menu/navigation" />
</LinearLayout>
我的XML片段:
<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"
android:screenOrientation="portrait"
tools:context=".Friends">
<Button
android:id="@+id/newfriendbutton"
android:layout_width="0dp"
android:layout_height="66dp"
android:text="@string/new_friend"
tools:layout_constraintTop_creator="1"
tools:layout_constraintRight_creator="1"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintRight_toRightOf="parent"
tools:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView6"
android:layout_width="395dp"
android:layout_height="wrap_content"
android:text="@string/instruct"
android:textAlignment="center"
app:layout_constraintTop_toBottomOf="@+id/newfriendbutton"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="8dp" />
<ListView
android:id="@+id/friendListView"
android:layout_width="match_parent"
android:layout_height="592dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView6"
tools:ignore="MissingConstraints"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1" />
</android.support.constraint.ConstraintLayout>
我想你應該嘗試解決您的佈局,'layout_height =「592dp」'不看的權利 –
沒有那不是問題 – Jupiter
你真的應該使用權,沒有固定的尺寸,雖然 –