如何最小化图像自动滑块的加载时间

时间:2016-10-01 10:45:01

标签: android xml android-layout material-design android-image

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

  <ViewFlipper
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:flipInterval="1000"
    android:autoStart="true">
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@mipmap/wow_image"
        android:contentDescription="@string/app_name" />
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@mipmap/transparent_water"/>

  <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@mipmap/tr"/>
  </ViewFlipper>

  </RelativeLayout>
  

我正在使用这个xml它的工作正常,但加载slider需要时间。我想更多地使用4到5个图像。任何建议

     

我实际上是在运行和启动应用程序

2 个答案:

答案 0 :(得分:0)

用这个

替换你的代码
<?xml version="1.0" encoding="utf-8"?>
  <RelativeLayout 
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent">

  <ViewFlipper
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:flipInterval="500"
    android:autoStart="true">
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@mipmap/wow_image"
        android:contentDescription="@string/app_name" />
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@mipmap/transparent_water"/>

  <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@mipmap/tr"/>
  </ViewFlipper>

  </RelativeLayout>

答案 1 :(得分:0)

添加以下行:

viewFlipper.setFlipInterval(YOUR TIME);