2017-12-27 12 views
-1

を使用しているとき、それは5 imagebuttonsに動作しますが、私は新しいものを追加しようとした場合、私はときに再利用するので、それは、これは奇妙である、「のOutOfMemoryエラー」でクラッシュし、クラッシュ以前使用していたボタンはうまくいきましたが、理由はわかりません。すべての画像は同じ背景(530x143)で、背景は透明です。アプリケーションは、私がScrollView</em><em>を使用する場合はScrollView

はここに私の.xmlだ、私はあなたが私を助けることを願って:

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentStart="true" 
    android:layout_alignParentTop="true"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <ImageButton 
      android:id="@+id/cat_ib1" 
      android:layout_width="235sp" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="71dp" 
      android:background="@android:color/transparent" 
      android:scaleType="fitCenter" 
      android:src="@drawable/categories_action" /> 

     <ImageButton 
      android:id="@+id/cat_ib2" 
      android:layout_width="235sp" 
      android:layout_height="wrap_content" 
      android:layout_alignStart="@+id/cat_ib1" 
      android:layout_below="@+id/cat_iv_csik" 
      android:layout_marginTop="56dp" 
      android:background="@android:color/transparent" 
      android:scaleType="fitCenter" 
      android:src="@drawable/categories_adventure" /> 

     <ImageButton 
      android:id="@+id/cat_ib3" 
      android:layout_width="235sp" 
      android:layout_height="wrap_content" 
      android:layout_alignStart="@+id/cat_ib2" 
      android:layout_below="@+id/cat_ib1" 
      android:layout_marginTop="25dp" 
      android:background="@android:color/transparent" 
      android:scaleType="fitCenter" 
      android:src="@drawable/categories_animation" /> 

     <ImageButton 
      android:id="@+id/cat_ib4" 
      android:layout_width="235sp" 
      android:layout_height="wrap_content" 
      android:layout_alignStart="@+id/cat_ib3" 
      android:layout_below="@+id/cat_ib2" 
      android:layout_marginTop="25dp" 
      android:background="@android:color/transparent" 
      android:scaleType="fitCenter" 
      android:src="@drawable/categories_anime" /> 

     <ImageButton 
      android:id="@+id/cat_ib5" 
      android:layout_width="235sp" 
      android:layout_height="wrap_content" 
      android:layout_alignStart="@+id/cat_ib4" 
      android:layout_below="@+id/cat_ib3" 
      android:layout_marginTop="25dp" 
      android:background="@android:color/transparent" 
      android:scaleType="fitCenter" 
      android:src="@drawable/categories_biography" /> 

     <ImageButton 
     android:id="@+id/cat_ib6" 
     android:layout_width="235sp" 
     android:layout_height="wrap_content" 
     android:layout_alignStart="@+id/cat_ib5" 
     android:layout_below="@+id/cat_ib4" 
     android:layout_marginTop="25dp" 
     android:background="@android:color/transparent" 
     android:scaleType="fitCenter" 
     android:src="@drawable/categories_cartoon" /> 

     <ImageButton 
      android:id="@+id/cat_ib7" 
      android:layout_width="235sp" 
      android:layout_height="wrap_content" 
      android:layout_alignStart="@+id/cat_ib6" 
      android:layout_below="@+id/cat_ib5" 
      android:layout_marginTop="25dp" 
      android:background="@android:color/transparent" 
      android:scaleType="fitCenter" 
      android:src="@drawable/categories_comedy" /> 

     <ImageButton 
      android:id="@+id/cat_ib8" 
      android:layout_width="235sp" 
      android:layout_height="wrap_content" 
      android:layout_alignStart="@+id/cat_ib7" 
      android:layout_below="@+id/cat_ib6" 
      android:layout_marginTop="25dp" 
      android:background="@android:color/transparent" 
      android:scaleType="fitCenter" 
      android:src="@drawable/categories_crime_gangster" /> 

     <ImageView 
      android:id="@+id/cat_iv_csik" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentStart="true" 
      android:layout_alignParentTop="true" 
      android:src="@drawable/csik" /> 


    </RelativeLayout> 


</ScrollView> 

をcat_ib5ボタンの後、私はアプリがクラッシュ行く別ののImageButtonを追加しようとするたびに。 (全体のコードはRelativeLayoutである)

+0

に、@の描画可能/ categories_biographyであなたのイメージを移動してみてくださいprogrammaticlyイメージソースを設定し、削減ビットマップを通してそれを設定し、参照してください[リンク](HTTPS :/stackoverflow.com/q/14235287/7569106)関連する –

+0

ドローイング可能な画像ビット重いのように見えます。 – Saveen

答えて

0

が描画可能xxhdpiフォルダ

関連する問題