Sorry! Just to clarify, I've also tried setting the ImageView's layout params as per the example using:
drawableContainer.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); Thanks! On Jun 30, 10:04 am, Cardy <[email protected]> wrote: > Hi, > > I'm trying to add a drawable to a layout, using an ImageView, but the > drawable doesn't maintain its size and is rendered at 1dp x 1dp. > > I've called ImageView.setAdjustViewBounds as per the android > documentation but this doesn't seem to help. The Drawable is only > visible when the ImageView's height and width are set and the drawable > is then rendered at those dimensions. > > Here's the code and layout: > > rect_blue.xml > ------------------- > > <?xml version="1.0" encoding="utf-8"?> > <shape xmlns:android="http://schemas.android.com/apk/res/android" > android:height="50dp" android:width="100dp" android:shape="rectangle"> > <solid android:color="#FFFF00FF" /> > <corners android:radius="5dp" /> > </shape> > > FlipView.java (Derived from FrameLayout) > ----------------------------------------------------------- > > ImageView drawableContainer = new ImageView(context); > drawableContainer.setImageResource(R.drawable.rect_blue); > drawableContainer.setAdjustViewBounds(true); > > this.AddView(drawableContainer); > > Layout Overview > ---------------------- > > RelativeLayout > -> FrameLayout > -> ImageView (With drawable set as content) > > I'm sure I'm doing pretty much exacly the same as the example > here:http://developer.android.com/guide/topics/graphics/2d-graphics.html. > Could it be because I'm using a FrameLayout that this is not working? > > Thanks! > > Andy -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

