2016-05-12 63 views
0

我有一個3頁的介紹。 我使用本教程,以實現刷卡頁面簡介: https://thepseudocoder.wordpress.com/2011/10/05/android-page-swiping-using-viewpager/android viewpager與圖像不匹配

這工作正常,但:

我的第一頁有一個圖像和文本。我的第二和第三頁只有文字沒有圖像。

如果我從頁面1滑動到頁面2或從2滑動到1,幻燈片動畫將會滯後。

現在,我發現了一個「解決方案」 如果我從網頁中刪除圖片1 =沒有滯後 與圖像=滯後

我的第一個網頁看起來是這樣的:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/Page1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:openDrawer="start"> 


    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/txt" 
     android:id="@+id/txt" /> 

    <ImageView 
     android:id="@+id/imageView3" 
     android:layout_gravity="center" 
     android:background="@drawable/image" 
     android:layout_width="183dp" 
     android:layout_height="281dp" 
     android:layout_centerVertical="true" 
     android:layout_centerHorizontal="true" /> 

</RelativeLayout> 
+0

你的圖像大小是多少? – Gauthier

+0

原始尺寸:640 x 987 px – Stack108

+0

現在呢? :( – Stack108

回答

1

我也有與使用ViewPager的文本的介紹圖像滑塊相同的問題。儘管圖像真的很小(〜90kB),但它完全是滯後的。

問題是,該圖像在res/drawable文件夾中。你應該將它們移動到res/drawable-hdpires/drawable-xhdpi或更高。

我猜不是文件大小,但圖像的分辨率導致了問題。