I'm using ViewFlipper, my viewFlipper was working properly till I increased the height of pictures.
It gives me OutOfMemoryError.
Here is my XML code for activity containing viewFlipper:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.taktaz.activities.OneProductActivity"
>
<ViewFlipper
android:id="@+id/flipper1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="450px"
android:clipChildren="true"
android:autoStart="true"
android:flipInterval="4000"
android:inAnimation="@anim/right_in"
android:outAnimation="@anim/left_out"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true">
</ViewFlipper>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:layout_margin="4dp"
>
<Button
android:id="@+id/btn_productDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/btn_product_specifics_style"
android:layout_marginBottom="1dp"
android:layout_weight="1"/>
<Button
android:id="@+id/btn_productCatalog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/btn_product_catalog_style"
android:layout_marginBottom="1dp"
android:layout_weight="1"/>
<Button
android:id="@+id/btn_productManual"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/btn_product_manual_style"
android:layout_marginBottom="1dp"
android:layout_weight="1"/>
<Button
android:id="@+id/btn_productWebsite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/btn_product_website_style"
android:layout_marginBottom="1dp"
android:layout_weight="1"
/>
</LinearLayout>
and here i set the viewFlipper ImageResources:
private void setUpFlipper() {
TypedArray imgResource = getResources().obtainTypedArray(R.array.hayabusa_imgs);
mFlipper = (ViewFlipper) findViewById(R.id.flipper1);
for (int i = 0 ; i < imgResource.length() ; i++)
{
ImageView imageView = new ImageView(this);
imageView.setImageResource(imgResource.getResourceId(i,-1));
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setAdjustViewBounds(true);
mFlipper.addView(imageView);
}
}
i didn't use Bitmaps.
when I remove buttons, viewFlipper works without errors, but when I put these 4 buttons bellow the flipper it not works, and will close with OutOfMemoryError.
What should I do?