The Clueless Programmer The Clueless Programmer - 4 months ago 6
Android Question

Putting in a drawable inside an image view

I am currently trying to put a draw-able inside a image view.

I've made a simple rounded rectangle as a drawable, and then put an imageview inside my layout, but for some reason it's not working.

The actual drawable is not showing up, and I'm left with a blank outline of the imageview container.

I am not sure what the problem is. My code is show below:

drawable speed_view_vw

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http//schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#b3ffff" />
<corners
android:radius = "3dp"/>
<size
android:width = "200dp"
android:height = "200dp"/>
</shape>


and the imageview:

<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/SpeedDisplay"
android:src="@drawable/speed_view_vw"
android:scaleType="fitXY"
android:contentDescription="@string/speed_image_desc"
android:layout_marginTop="74dp"
android:layout_below="@+id/Title"
android:layout_centerHorizontal="true" />


Currently, I only have a rounded rectangle, but in the end I want to produce something like this:

The two limes move according to parameters

So that the two bars move according to user parameters

Answer

add intrinsic bounds,in drawable speed_view_vw

  <size android:width="xxdp"
      android:height="xxdp"/>

or try your drawable like this with layer-list and will work

or

Found your issue its with

 http

replace this

<shape xmlns:android="http//schemas.android.com/apk/res/android"

with this http:

<shape xmlns:android="http://schemas.android.com/apk/res/android"