ScrollView - Layoutproblem -> dringend!

Chaoz

Chaoz

Fortgeschrittenes Mitglied
13
Hey Leute,

ich muss "schnell" ne neue version fertig stellen und hab folgendes problem:
In meinem (root -linear) layout habe ich eine ScrollView und kurz darauf noch eine TextView. Beide haben das Attribut wrap_content, das LinearLayout hat fill_parent.

Das Problem: da ich innerhalb der ScrollView über den javaCode neue Komponenten anhänge, geht die ScrollView bis zum unteren Ende des displays und die TextView ist nicht mehr sichtbar. =(

kurzfassung der xml (abstrakt):

<linear fill_parent>
<ScrollView>
<Table>//im javacode werden neue rows geaddet
</Table>
</ScrollView>
<TextView /> //nicht sichtbar!
</linear>


code:

Code:
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearRoot"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ScrollView android:id="@+id/ScrollView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <TableLayout android:id="@+id/TableLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:stretchColumns="1">
        </TableLayout>

    </ScrollView>

<TextView android:text="Footer" android:id="@+id/Footer"
                    android:layout_width="wrap_content" android:layout_height="wrap_content"
                    android:padding="8dip">
                </TextView>
</LinearLayout>
Im JavaCode adde ich neue Rows dann mit:
Code:
TableLayout oTable = null;
oTable = (TableLayout) findViewById(R.id.TableLayout);
oTable.addView(myRow);
 
Zuletzt bearbeitet:
schau mal hier, der macht da glaube ich sowas ähnliches
 
  • Danke
Reaktionen: camelot und Chaoz
hm, aber welchen Sinn hat denn ein Element unter einer ScrollView?
Irgendwie kommt mir das extrem sinnlos vor...
Klär mich bitte auf!

jup, hab mir mal den ersten link angeschaut, macht wohl doch Sinn.
 
Zuletzt bearbeitet:
zugegeben, es istn fieser hack, aber es ist genau DER fiese hack, den ich gerade brauch. ^^


Kaum zu glauben dass das so umständlich ist.
Danke euch beide :)
 
Fr4gg0r schrieb:
hm, aber welchen Sinn hat denn ein Element unter einer ScrollView?
Irgendwie kommt mir das extrem sinnlos vor...
Klär mich bitte auf! :o

Naja... anstelle einem Header mit Logo gibts n Footer mit Logo.
Ist bei mir designVorgabe vom chef, kann ich nix für. ^^
 
Fr4gg0r schrieb:
hm, aber welchen Sinn hat denn ein Element unter einer ScrollView?
Irgendwie kommt mir das extrem sinnlos vor...
Klär mich bitte auf! :o

bei mir eine button bar. designvorgabe war, du hast es sicher schon erraten, unten :).
 
Hrhr... das erinnert mich unfreiwillig an viele kiddy-foren, wo erstmal totgefragt wird warum man es denn "so" machen wolle und wie doof das eigtl sei. xD Die wenigstens haben wirklich ahnung von halbwes professioneller softwareentwicklung und versuchen sich nur zu profilieren oder andere schlecht dastehen zu lassen, ohne (wichtig!) dabei das problem zu lösen.

...zum glück ist das hier nicht so. :)
 
Hmm not really a elegant solution for the button at the bottom.
A nice solution would be the following:

Code:
<ScrollView 
   android:id="@+id/ScrollView01" 
   android:layout_height="1dip" 
   android:layout_width="fill_parent"
   android:layout_weight="1">
          <RadioGroup android:id="@+id/RadioGroup01" android:layout_width="wrap_content" android:layout_height="wrap_content">
               <RadioButton android:id="@+id/RadioButton01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />
               <RadioButton android:id="@+id/RadioButton11" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button....." />       
          </RadioGroup>
     </ScrollView>
     <Button 
        android:id="@+id/Button01" 
        android:layout_height="wrap_content" 
        android:layout_width="fill_parent" 
        android:text="A button that should always be at the bottom"/>
Using the weight attribute saves ...well not so nice absolute margins (producing problems when different screensizes (50dip is a LOT for a QVGS screen)). And it saves you the relative layout.

This is easy and good :)

Greets

VIDEN
 

Ähnliche Themen

D
Antworten
10
Aufrufe
926
DagobertDokate
DagobertDokate
H
Antworten
2
Aufrufe
871
haner
H
N
Antworten
11
Aufrufe
1.615
Nonsens
N
Zurück
Oben Unten