To really understand why the xml is behaving the way it is, we'd probably need to see more of the xml file. For example, what are the parent xml objects using?
-Kitzy On Apr 13, 3:28 am, "jrichards1...@googlemail.com" <jrichards1...@googlemail.com> wrote: > Hi. does anybody have any idea please on how to set the size of my > custom view using android:layout_height and android:layout_width? > > On Apr 5, 7:38 pm, "jrichards1...@googlemail.com" > > <jrichards1...@googlemail.com> wrote: > > As the title says, i am trying to use acustomviewi have created > > andinitializingthe size of it using the abovexmlcode snippet located > > inside my layout folder.: > > > <com.Resources.Gui.ScrollingText android:id="@+id/rss" > > android:layout_height="wrap_content" > > android:layout_alignParentBottom="true" > > android:layout_width="wrap_content" /> > > > The height and width of mycustomviewdoesnt seem to work. i have to > > manualy hard code it to adjust and see mycustomviewusing the bit of > > code below located on my main activity class: > > > rssText = (ScrollingText) findViewById(R.id.rss); > > rssText.setWidthHeight(200,50); > > > Code below is the ScrollingText methods. > > > Constructor: > > public ScrollingText(Context context, AttributeSet attrs) { > > super(context, attrs); > > > textPaint = new Paint(Paint.ANTI_ALIAS_FLAG); > > textPaint.setColor(Color.BLACK); > > textBoxPaint = new Paint(Paint.ANTI_ALIAS_FLAG); > > textBoxPaint.setColor(Color.WHITE); > > textPaint.setTextSize(20); > > > } > > > public void setWidthHeight(int width, int height){ > > this.height = height; > > this.width = width; > > } > > > private void drawTextBox(Canvas c) { > > > // TODO: Experiment with these co-ordinates > > c.drawRect(10, 0, width - 10, height, textBoxPaint); > > > } > > > private void drawTextRss(Canvas c) { > > int textHeight = (int) textPaint.getTextSize(); > > printDebug("text height = "+ textHeight); > > c.drawText(text, 10, height + 10, textPaint); > > //c.drawText("Hello, why doesnt this work????????????", 10, > > 50, > > textPaint); > > } > > > @Override > > protected void onDraw(Canvas canvas) { > > // TODO Auto-generated method stub > > super.onDraw(canvas); > > drawTextBox(canvas); > > drawTextRss(canvas); > > setVisibility(VISIBLE); > > } > > > @Override > > protected void onMeasure(int widthMeasureSpec, int > > heightMeasureSpec) > > { > > > setMeasuredDimension(width,height); > > } > > > I hope my explanations and code is enough to help me figure out how i > > can set the size of thecustomviewfrom thexmllayout file. > > > Not sure why android:layout_height="wrap_content" > > android:layout_width="wrap_content" doesnt ?????? > > -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en To unsubscribe, reply using "remove me" as the subject.