首先,我是新來的機器人,所以如果我錯過了一些基本的道歉。Android的ListView寬度不斷變化
我有一個頁面有兩個並排的ListViews,兩個都有不同數量的內容。我也有ListView上方的TextView和列表視圖下方的另一個TextView。這些文本視圖框基於在兩個ListView中選擇的項目而改變。
這兩個ListView並排坐在一起,佔用每個屏幕的一半,而Textview直接位於上方和正下方,均位於頁面中央。圖像如下所示。
This is the page looking normal on load.
的問題是,當我從任一列表中選擇一個項目。我有一種感覺我錯過了一些XML屬性,但我不確定哪些屬性或者甚至是這種情況。當選擇一個項目時,讓我們從右側的ListView中看到,底部的TextView更新了從數組中取得的文本。 ListView也決定改變寬度,我不知道爲什麼這是....我不希望ListView改變寬度。我希望它只佔用頁面的一半和頁面的一半。
This is the page after an item from the right ListView has been selected.
我也想保持對事物的RelativeLayout的。我也相信這只是一個XML問題,不適用於適配器或任何其他代碼,所以我現在不會包含它。如果需要,我可以包含它。
任何幫助將是偉大的。提前致謝。
content_titles.xml我的活動XML文件
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TitlesActivity">
<ListView
android:id="@+id/unlocked_titles_list"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:longClickable="true"
android:layout_below="@+id/current_title"
android:layout_alignEnd="@+id/requirements"
android:layout_marginEnd="26dp"
android:layout_above="@+id/requirements">
</ListView>
<TextView
android:id="@+id/current_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="65dp"
android:text="Current Title: Novice"
android:textSize="24sp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"/>
<ListView
android:id="@+id/locked_titles_list"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignStart="@+id/requirements"
android:layout_marginStart="28dp"
android:layout_above="@+id/requirements"
android:layout_below="@+id/current_title"/>
<TextView
android:id="@+id/requirements"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="34dp"
android:text="temp"
android:textAlignment="center"
android:textSize="24sp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
activity_listview.xml用作列表視圖
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
android:textSize="16dip"
android:textStyle="bold" >
</TextView>
我真的想保持在RelativeLayout中。有另一種方法嗎? –