Fabian W.
- Forum-Beiträge: 17
13.05.2012, 20:59:19 via Website
13.05.2012 20:59:19 via Website
Hallo,
folgendes Problem:
Ich habe eine ListView in der ich Nachrichten ausgebe. In jedem Element ist ein Image, der Name des Verfassers und die Nachricht selbst.
Die ListView selbst, und deren Inhalt sind in 2 verschiedenen xml - Datein gespeichert.
Das Problem ist, dass wenn der Nachrichtentext zu groß wird, verschwindet er hinter dem nächsten ListView Element...
Hier die xml´s:
Die LsitView selbst:
Und der Inhalt der ListView:
Kann man das so anpassen, dass sich die ListView an die Größe des Testfelds anpasst?
Danke für die Hilfe, Fabian
folgendes Problem:
Ich habe eine ListView in der ich Nachrichten ausgebe. In jedem Element ist ein Image, der Name des Verfassers und die Nachricht selbst.
Die ListView selbst, und deren Inhalt sind in 2 verschiedenen xml - Datein gespeichert.
Das Problem ist, dass wenn der Nachrichtentext zu groß wird, verschwindet er hinter dem nächsten ListView Element...
Hier die xml´s:
Die LsitView selbst:
1<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2 android:layout_width="fill_parent"
3 android:layout_height="fill_parent" >
4
5 <ListView
6 android:id="@android:id/list"
7 android:layout_width="match_parent"
8 android:layout_height="wrap_content"
9 android:stackFromBottom="true"
10 android:divider="#000000"
11 android:dividerHeight="2px"
12 android:layout_above="@+id/etText" />
13
14 <EditText
15 android:id="@+id/etText"
16 android:layout_width="wrap_content"
17 android:layout_height="wrap_content"
18 android:layout_alignParentBottom="true"
19 android:layout_alignParentLeft="true"
20 android:layout_toLeftOf="@+id/button1"
21 android:ems="10"
22 android:hint="Nachricht hier eingeben"
23 android:inputType="textMultiLine" >
24
25 <requestFocus />
26 </EditText>
27
28 <Button
29 android:id="@+id/button1"
30 android:layout_width="wrap_content"
31 android:layout_height="wrap_content"
32 android:layout_alignParentBottom="true"
33 android:layout_alignParentRight="true"
34 android:text="Senden"
35 android:clickable="false"
36 android:onClick="ButtonSend" />
37
38 </RelativeLayout>
2 android:layout_width="fill_parent"
3 android:layout_height="fill_parent" >
4
5 <ListView
6 android:id="@android:id/list"
7 android:layout_width="match_parent"
8 android:layout_height="wrap_content"
9 android:stackFromBottom="true"
10 android:divider="#000000"
11 android:dividerHeight="2px"
12 android:layout_above="@+id/etText" />
13
14 <EditText
15 android:id="@+id/etText"
16 android:layout_width="wrap_content"
17 android:layout_height="wrap_content"
18 android:layout_alignParentBottom="true"
19 android:layout_alignParentLeft="true"
20 android:layout_toLeftOf="@+id/button1"
21 android:ems="10"
22 android:hint="Nachricht hier eingeben"
23 android:inputType="textMultiLine" >
24
25 <requestFocus />
26 </EditText>
27
28 <Button
29 android:id="@+id/button1"
30 android:layout_width="wrap_content"
31 android:layout_height="wrap_content"
32 android:layout_alignParentBottom="true"
33 android:layout_alignParentRight="true"
34 android:text="Senden"
35 android:clickable="false"
36 android:onClick="ButtonSend" />
37
38 </RelativeLayout>
Und der Inhalt der ListView:
1<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2 android:layout_width="fill_parent"
3 android:layout_height="?android:attr/listPreferredItemHeight"
4 android:padding="6dip"
5 android:background="#c0c0c0" >
6
7 <ImageView
8 android:id="@+id/icon"
9 android:layout_width="wrap_content"
10 android:layout_height="fill_parent"
11 android:layout_alignParentLeft="true"
12 android:layout_centerVertical="true"
13 android:src="@drawable/ic_contact_picture" />
14
15 <TextView
16 android:id="@+id/absender"
17 android:layout_width="wrap_content"
18 android:layout_height="wrap_content"
19 android:layout_alignParentRight="true"
20 android:layout_alignTop="@+id/icon"
21 android:layout_toRightOf="@+id/icon"
22 android:text="Chatpartner"
23 android:textAppearance="?android:attr/textAppearanceMedium"
24 android:textColor="#000000"
25 android:textStyle="bold" />
26
27
28
29 <TextView
30 android:id="@+id/nachricht"
31 android:layout_width="wrap_content"
32 android:layout_height="wrap_content"
33 android:layout_alignBottom="@+id/icon"
34 android:layout_alignLeft="@+id/absender"
35 android:layout_alignRight="@+id/absender"
36 android:layout_below="@+id/absender"
37 android:text="Nachricht"
38 android:textAppearance="?android:attr/textAppearanceSmall"
39 android:textColor="#333333" />
40
41 </RelativeLayout>
2 android:layout_width="fill_parent"
3 android:layout_height="?android:attr/listPreferredItemHeight"
4 android:padding="6dip"
5 android:background="#c0c0c0" >
6
7 <ImageView
8 android:id="@+id/icon"
9 android:layout_width="wrap_content"
10 android:layout_height="fill_parent"
11 android:layout_alignParentLeft="true"
12 android:layout_centerVertical="true"
13 android:src="@drawable/ic_contact_picture" />
14
15 <TextView
16 android:id="@+id/absender"
17 android:layout_width="wrap_content"
18 android:layout_height="wrap_content"
19 android:layout_alignParentRight="true"
20 android:layout_alignTop="@+id/icon"
21 android:layout_toRightOf="@+id/icon"
22 android:text="Chatpartner"
23 android:textAppearance="?android:attr/textAppearanceMedium"
24 android:textColor="#000000"
25 android:textStyle="bold" />
26
27
28
29 <TextView
30 android:id="@+id/nachricht"
31 android:layout_width="wrap_content"
32 android:layout_height="wrap_content"
33 android:layout_alignBottom="@+id/icon"
34 android:layout_alignLeft="@+id/absender"
35 android:layout_alignRight="@+id/absender"
36 android:layout_below="@+id/absender"
37 android:text="Nachricht"
38 android:textAppearance="?android:attr/textAppearanceSmall"
39 android:textColor="#333333" />
40
41 </RelativeLayout>
Kann man das so anpassen, dass sich die ListView an die Größe des Testfelds anpasst?
Danke für die Hilfe, Fabian
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.