Frage zur Scrollview

  • 5 Antworten
  • Letztes Antwortdatum
kukuk

kukuk

App-Anbieter (kostenlos)
37
Ich habe das Problem, wenn ich die Scrollfunktion auf der Activity einbaue, werden die steuerelemente ganz nach links gepackt. Ohne Scrollview u.s.w sah alles super aus. ich bekomm die Elemente nicht mittig hin.
Kann mir da jemand helfen?

Ich verwende folgenden xml code:

Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/Info_Layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000100"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".InfoActivity" >
  <ScrollView
          android:id="@+id/layout"
    android:layout_width="wrap_content"
             android:layout_height="match_parent" > >
          
      <HorizontalScrollView
          android:id="@+id/horizontalView"
          android:layout_width="334dp"
          android:layout_height="438dp"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true"
          android:layout_marginTop="10dp"
          android:scrollbars="horizontal|vertical" >

          <TableLayout
              android:id="@+id/tableLayout1"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_alignParentTop="true"
              android:layout_centerHorizontal="true"
              android:layout_marginTop="13dp" >

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

                  <ImageView
                      android:id="@+id/widget_image"
                      android:layout_width="150sp"
                      android:layout_height="150sp"
                      android:layout_gravity=""
                      android:contentDescription="@string/aenderungen_speichern"
                      android:src="@drawable/test" />
              </TableRow>

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

                  <TextView
                      android:id="@+id/textView001"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:gravity="center"
                      android:text="@string/aenderungen_speichern"
                      android:textColor="#FFFFFF" />
              </TableRow>

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

                  <TextView
                      android:id="@+id/textView1"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="TextView"
                      android:visibility="invisible" />
              </TableRow>

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

                  <TextView
                      android:id="@+id/textView2"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:gravity="center"
                      android:text="@string/aenderungen_speichern"
                      android:textColor="#FFFFFF" />
              </TableRow>

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

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

                  <ImageView
                      android:id="@+id/imageView2"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_marginTop="30dp"
                      android:onClick="credits_anzeigen"
                      android:src="@drawable/credits" />
              </TableRow>

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

                  <TextView
                      android:id="@+id/textView3"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="TextView"
                      android:visibility="invisible" />
              </TableRow>

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

                  <ImageView
                      android:id="@+id/imageView1"
                      android:layout_width="100sp"
                      android:layout_height="100sp"
                      android:layout_marginLeft="10dp"
                      android:onClick="spenden"
                      android:src="@drawable/spenden" />
              </TableRow>
          </TableLayout>
      </HorizontalScrollView>

    
      </ScrollView>
      
</RelativeLayout>
 
Hi,

Code:
<ScrollView
   android:id="@+id/layout"
   android:layout_width="match_parent"
   android:layout_height="match_parent" >

Gruß
 
  • Danke
Reaktionen: kukuk
In Eclipse wir das komplett falsche angezeigt. Am Handy siehts aus so wie ich das haben möchte....


Ich habe noch ne Frage:

Ich habe als Anhang noch ein Screenshot hochgeladen.

Wie kann ich denn jetzt die Images richtig positionieren???
 

Anhänge

  • table.png
    table.png
    14 KB · Aufrufe: 182
Was meinst du mit "richtig"? wo willst du sie haben und wo sind die jetzt?

Gesendet von meinem Nexus 10 mit der Android-Hilfe.de App
 
Habs jetzt hinbekommen mit

android:layout_marginLeft="-150dp"
 
Ok.. so generell..
negative Margins sind immer ein Zeichen dafür, dass man anderswo was falsch gemacht hat.

Du sagst deinem TableLayout ja:
android:layout_centerHorizontal="true"

Deshalb sind die Bilder auch zentriert.

Ich bin mir sicher, dass du mit dem negativen Margin auf einigen Geräten die Grafik nach links aus dem Bildschirm rausschiebst.

Bau doch einfach ein LinearLayout mit width auf "match_parent" um das Image rum das sollte eigentlich funktionieren.
 
  • Danke
Reaktionen: kukuk
Zurück
Oben Unten