LinearLayout und TextView in ein Drawer Layout einfügen

  • Antworten:3
  • Bentwortet
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

18.02.2014, 19:19:17 via Website

Hallo,
ich habe mir mit der SupportLib ein Drawerlayout zusammengebaut, dieses enthält im Schiebemenü auf der Linken seite ein linearlayout in der sich eine ListView zum navigieren befindet.
Ich wll nun in dieses Linear Layout eine TextView zusetzlich einfügen. Wenn ich das aber tue, dann bringt mir LogCat eine Runtime Exception und verweist auf meine DrawerLayout XML Datei. kann ich überhaupt in einem NavigationDrawer andere Elemente haben?
Hier noch mein Layout:
1<!-- Drumrum noch ein Support v4 Drawer layout-->
2 <LinearLayout
3 android:id="@+id/left_drawer"
4 android:layout_width="240dp"
5 android:layout_height="match_parent"
6 android:layout_gravity="start"
7 android:background="@android:color/white"
8 android:orientation="horizontal" >
9
10<!-- hier soll die TextView rein
11so:
12
13 <TextView
14 android:text="Hallo, Android!">
15 </TextView>
16
17
18
19-->
20
21
22 <ListView android:id="@+id/left_drawer_list"
23 android:layout_width="match_parent"
24 android:layout_height="match_parent"
25 android:choiceMode="singleChoice"
26 style="@style/ListViewItem"
27 android:divider="@android:color/white"
28
29 android:background="@android:color/white"
30 />
31</LinearLayout>

LG

Pascal

— geändert am 18.02.2014, 20:10:10

LG Pascal //It's not a bug, it's a feature. :) ;)

Antworten
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

26.02.2014, 20:04:15 via Website

Habs jetzt hinbekommen, mein nächstes Problem ist, dass ich eine ListView habe und darunter will ich noch eine TextView anhängen. Jetzt habe ich das Problem, dass ich die ListView nicht in eine ScrollView packen kann, damit ich die LV nach oben schieben und dann unten die TextView sehen kann.
Horizontal ist das anschauen kein Problem, aber wenn ich mein Handy drehe, sehe ich nur noch alle LV einträge und nicht die Darunter befindliche ListView. Habt ihr eine Idee wie ich das Lösen kann?

Hier noch das besagte Layout:
1<?xml version="1.0" encoding="utf-8"?>
2
3 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
4 android:layout_width="match_parent"
5 android:layout_height="match_parent"
6 android:orientation="vertical" >
7
8
9 <ListView
10 android:id="@+id/left_drawer_list"
11 style="@style/ListViewItem"
12 android:layout_width="match_parent"
13 android:layout_height="wrap_content"
14 android:background="@android:color/white"
15 android:choiceMode="singleChoice"
16 android:divider="@android:color/white"
17<!-- Die Liste ist auf dem Bildschirm zu groß, sodass ich die Darunterliegende ScrollView nicht mehr sehe-->
18 />
19
20
21 <ScrollView
22 android:layout_width="240dp"
23 android:background="@android:color/white"
24 android:layout_height="match_parent" >
25
26
27 <LinearLayout
28 android:layout_width="match_parent"
29 android:layout_height="wrap_content"
30 android:id="@+id/left_drawer_scroller"
31 android:orientation="vertical">
32
33
34
35 <!-- in dieses Layout kommt Später per Programm die TextView-->
36
37
38
39 </LinearLayout>
40
41
42</ScrollView>
43
44 </LinearLayout>

— geändert am 26.02.2014, 20:05:10

LG Pascal //It's not a bug, it's a feature. :) ;)

Antworten
impjor
  • Forum-Beiträge: 1.793

26.02.2014, 21:40:35 via App

Du hast also eine ListView und darunter eine ScrollView? Beide Views kann man ja scrollen, d.h. du musst dich entscheiden, wie viel % des Bildschirms beide einnehmen dürfen. (z.B. 50/50, 90/10, usw.).
Also setzt du die Höhe von ScrollView und ListView auf 0dp und gibt's ihnen eine entsprechende weight.

LG

Liebe Grüße impjor.

Für ein gutes Miteinander: Unsere Regeln
Apps für jeden Einsatzzweck
Stellt eure App vor!

Antworten
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

26.02.2014, 21:50:42 via App

Danke ich glaube das ist das wonach ich gesucht habe.
Werde es morgen Testen.

LG

Pascal

LG Pascal //It's not a bug, it's a feature. :) ;)

Antworten