2016-06-03 9 views
3

Ich möchte diesen Tutorial Fluss neu erstellen: iOS ScreenshotScroll in ViewPager Position nicht richtig

Also habe ich folgendes Haupt Layout:

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/tutorial_pager" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"/> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="@dimen/tutorial_pairing_padding"> 

     <Button 
      android:id="@+id/left" 
      style="@style/TutorialButtonOutline" 
      android:layout_width="100sp" 
      android:layout_height="wrap_content" 
      android:layout_margin="0dp" 
      android:text="@string/skip"/> 

     <com.viewpagerindicator.CirclePageIndicator 
      android:id="@+id/tutorial_indicator" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_weight="1"/> 

     <Button 
      android:id="@+id/right" 
      style="@style/TutorialButton" 
      android:layout_width="100sp" 
      android:layout_height="wrap_content" 
      android:layout_margin="0dp" 
      android:text="@string/next"/> 
    </LinearLayout> 

</LinearLayout> 

in Java, es ist ziemlich straigtforward ist Activity basierend auf AppCompatActivity die initialisiert ViewPager und setzt FragmentPagerAdapter. Der FragmentPagerAdapter Adapter sieht wie folgt aus:

class TutorialMonitoringPageAdapter extends FragmentPagerAdapter { 

    TutorialMonitoringPageAdapter(final FragmentManager fm) { 
     super(fm); 
    } 

    @Override 
    public Fragment getItem(final int position) { 
     switch (position) { 
      case 0: 
       return new FragmentTutorialMonitoring1(); 
      case 1: 
       return new FragmentTutorialMonitoring2(); 
      case 2: 
       return new FragmentTutorialMonitoring3(); 
      default: 
       return null; 
     } 
    } 

    @Override 
    public int getCount() { 
     return 3; 
    } 
} 

Die FragmentTutorialMonitoringN Klassen bläht nur die folgenden Layouts:

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    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_gravity="center" 
     android:gravity="center" 
     android:orientation="vertical" 
     android:paddingLeft="@dimen/tutorial_pairing_padding" 
     android:paddingRight="@dimen/tutorial_pairing_padding"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:text="@string/monit_tutor_first_title" 
      android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"/> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:srcCompat="@drawable/child_monitoring1"/> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:text="@string/monit_tutor_first_text" 
      android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"/> 

    </LinearLayout> 

</ScrollView> 

Aber wenn ich die App starten, wird der oberste Text hinter dem ActionBar versteckt und das Scrollen ist alles komisch (es "versteckt" sich hinter den Tasten). Sehen Sie es auf Video:

https://youtu.be/Xd6xwmGW3Qc

Was mache ich falsch?

Ich habe versucht:

  • fillViewport von ScrollView
  • ScrollView viel vollständig
  • Einstellung fester Höhe zu ViewPager (und Entfernen layout_height)

Und nichts geändert Entfernen Entfernen.

+1

was genau möchten Sie erreichen? –

+0

@ankitaggarwal Korrektes Verhalten von 'ScrollView' (kein Bild außerhalb des Bildschirms) – Pitel

Antwort

0

Entfernen layout_gravity von ScrollView 's Kind behebt das Problem.

Verwandte Themen