vendredi 10 avril 2015

App stops working when adding image to imageButton

I am trying to make an scrollview with some imageButtons.


If i create it with blank buttons it works great.


My xml is:



<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainScreen">


<HorizontalScrollView
android:id="@+id/filtersScroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">

<LinearLayout
android:id="@+id/filtersLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<ImageButton
android:id="@+id/filtro1"
android:layout_width="64dp"
android:layout_height="64dp"/>
<ImageButton
android:id="@+id/filtro2"
android:layout_width="64dp"
android:layout_height="64dp" />
<ImageButton
android:id="@+id/filtro3"
android:layout_width="64dp"
android:layout_height="64dp"/>
<ImageButton
android:id="@+id/filtro4"
android:layout_width="64dp"
android:layout_height="64dp"/>
<ImageButton
android:id="@+id/filtro5"
android:layout_width="64dp"
android:layout_height="64dp"/>
<ImageButton
android:id="@+id/filtro6"
android:layout_width="64dp"
android:layout_height="64dp"/>
<ImageButton
android:id="@+id/filtro7"
android:layout_width="64dp"
android:layout_height="64dp"/>
<ImageButton
android:id="@+id/filtro8"
android:layout_width="64dp"
android:layout_height="64dp"/>




</LinearLayout>

</HorizontalScrollView>


And what i get is: Emulation picture


But when i add a picture to the drawable folder(don't know if it matters but the picture is 2000x2000) and add it to one of the imageButtons like so:



<ImageButton
android:id="@+id/filtro1"
android:layout_width="64dp"
android:layout_height="64dp"
android:scaleType="centerInside"
android:src="@drawable/smiley" />


Not only i can't make the image resize to the size of the button, but the app also stops working as soon as i try to run it.


This is how the preview looks like:


buttonPreview


What am i missing? Has it something to do with the size of the source picture? I mean, i just want it to resize to the size of the button and work.


Also, what happened to the other folders that used to be in drawable/ ? Now you don't have to separate the images according to their size?


Aucun commentaire:

Enregistrer un commentaire