2016-07-11 8 views
0

Ich habe die folgende Möglichkeit, Kachelansicht von jeder Rastergröße zu haben. Aber ich will nur 2x3 Kacheln auf der Seite und 2x1 auf dem unter dem sichtbaren Teil der Seite. Auf die Sie nur nach dem Blättern der Seite zugreifen können. Aber ich kann das nicht mit der folgenden Methode erreichen.Scrollable Tile View in android

Ich versuchte Scroll-Ansicht für die gesamte view.xml, aber dann wurde es zum oberen Rand der Seite geschrumpft. Und ich habe keine Kontrolle über die Größe der Fliesen. Die Änderung entsprechend der Ansicht.

view.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dip" 
      android:orientation="horizontal" 
      android:layout_weight="1" > 

      <Button 
       android:layout_width="0dip" 
       android:layout_height="match_parent" 
       android:layout_weight="1" /> 

      <Button 
       android:layout_width="0dip" 
       android:layout_height="match_parent" 
       android:layout_weight="1"/> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dip" 
      android:orientation="horizontal" 
      android:layout_weight="1" > 

      <Button 
       android:layout_width="0dip" 
       android:layout_height="match_parent" 
       android:layout_weight="1" /> 

      <Button 
       android:layout_width="0dip" 
       android:layout_height="match_parent" 
       android:layout_weight="1"/> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dip" 
      android:orientation="horizontal" 
      android:layout_weight="1" > 

      <Button 
       android:layout_width="0dip" 
       android:layout_height="match_parent" 
       android:layout_weight="1" /> 

      <Button 
       android:layout_width="0dip" 
       android:layout_height="match_parent" 
       android:layout_weight="1" /> 
     </LinearLayout> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dip" 
      android:orientation="horizontal" 
      android:layout_weight="1" > 

      <Button 
       android:layout_width="0dip" 
       android:layout_height="match_parent" 
       android:layout_weight="1" /> 

      <Button 
       android:layout_width="0dip" 
       android:layout_height="match_parent" 
       android:layout_weight="1" /> 
     </LinearLayout> 
    </LinearLayout> 

enter image description here

Antwort

0

prüften Sie diese Struktur Layout:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical"> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fillViewport="true"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="30dp" 
      android:orientation="vertical"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="0dip" 
       android:layout_weight="1" 
       android:orientation="horizontal"> 

       <Button 
        android:layout_width="0dip" 
        android:layout_height="match_parent" 
        android:layout_weight="1"/> 

       <Button 
        android:layout_width="0dip" 
        android:layout_height="match_parent" 
        android:layout_weight="1"/> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="0dip" 
       android:layout_weight="1" 
       android:orientation="horizontal"> 

       <Button 
        android:layout_width="0dip" 
        android:layout_height="match_parent" 
        android:layout_weight="1"/> 

       <Button 
        android:layout_width="0dip" 
        android:layout_height="match_parent" 
        android:layout_weight="1"/> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="0dip" 
       android:layout_weight="1" 
       android:orientation="horizontal"> 

       <Button 
        android:layout_width="0dip" 
        android:layout_height="match_parent" 
        android:layout_weight="1"/> 

       <Button 
        android:layout_width="0dip" 
        android:layout_height="match_parent" 
        android:layout_weight="1"/> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="0dip" 
       android:layout_weight="1" 
       android:orientation="horizontal"> 

       <Button 
        android:layout_width="0dip" 
        android:layout_height="match_parent" 
        android:layout_weight="1"/> 

       <Button 
        android:layout_width="0dip" 
        android:layout_height="match_parent" 
        android:layout_weight="1"/> 
      </LinearLayout> 
     </LinearLayout> 
    </ScrollView> 

</LinearLayout> 
+0

android: fillViewport = "true" hinzufügen, um dieses Objekt innerhalb Scroll – comeback4you

+0

Danke für Antwort. Ich habe nachgesehen. Aber es funktioniert nicht. Es zeigt 4x2 gird auf der Hauptseite. Ich möchte 3x2 Gitter auf der Hauptseite und wenn ich nach oben scrolle, sollte es auch die unteren zwei anzeigen. Funktioniert Ihre Antwort für Sie? Probieren Sie es einfach aus ... – impossible

+0

@ArewegoodQ ok, nur eine Minute –