2017-12-25 12 views
0

ImageButton을 내 앱에 추가하면 (배경이 없음) 앱이 다운됩니다. 내가 코드를 다음과 같습니다이미지 버튼이 앱을 닫습니다.

<ImageButton 
    android:id="@+id/ib_main_home" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/home" 
    android:background="@null" 
    android:scaleType="fitCenter" 
    /> 

<ImageButton 
    android:id="@+id/ib_main_categories" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/categories" 
    android:background="@null" 
    android:scaleType="fitCenter" 
    /> 

<ImageButton 
    android:id="@+id/ib_main_actors" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/actors" 
    android:background="@null" 
    android:scaleType="fitCenter" 
    /> 

<ImageButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/twitter" 
    android:background="@null" 
    android:scaleType="fitCenter" 
    /> 

<ImageButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/facebook" 
    android:background="@null" 
    android:scaleType="fitCenter" 
    /> 

<ImageButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/instagram" 
    android:background="@null" 
    android:scaleType="fitCenter" 
    /> 

(전체 XML이 에 RelativeLayout의) ... @null없이 이미지가 화면보다 더 보여줍니다. 버튼이 전체 화면을 채 웁니다. 누구든지 나를 도울 수 있습니까?

+0

'background'에'@ null '을 사용하지 마십시오. 투명하게 만들려면 이렇게하십시오 :'android : background = "@ android : color/transparent"' –

+0

너무 충돌합니다 ... –

+0

The Logcat : java.lang.OutOfMemoryError : 16777120 여유 바이트로 74649612 바이트 할당을 할당하지 못했습니다. 55MB까지 OOM –

답변

0

오류가 java.lang.OutOfMemoryError라는 귀하의 의견에 따르면, 배경에로드하려고하는 이미지 중 하나 이상이 너무 많은 메모리를 차지하는 것으로 보입니다. 이 너무 커서입니다. 가장 쉬운 해결책은 이미지를 크기로 축소 (그리고 앱 크기를 줄임)하는 것입니다. 수동으로 크기를 조정하거나 같은 온라인으로 제공하는 솔루션 중 하나를 사용할 수 있습니다 http://resizeimage.net/

0

더 나은 결과를 위해 wrap_content을 제거하고 이미지 당신의 자아를 확장 할 수 있습니다. 원본 이미지의 크기를 줄일 수 있습니다. wrap_content도 제거하면 background="@null"을 제거하면 도움이 될 수 있습니다. 이 ImageView를 어떻게 구성하고 싶은지 말해주십시오. 복합보기를 만들기 위해 'merge'태그를 사용할 수 있습니다 (이 내용은 link 참조).