I posted earlier with a less clear title. Unless someone can show me
differently, I think I've found another bug in TextView.

res/values/colors.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
        <drawable name="red_drawable">#FF0000</drawable>
</resources>

res/layout/main.xml:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android";
        android:id="@+id/textview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="There should be a red strip at the bottom of this
view, not a red background"
/>

src/eyebrowssoftware/showcompounddrawablesproblem/ShowIt.java:

package com.eyebrowssoftware.showcompounddrawablesproblem;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.TextView;

public class ShowIt extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Drawable paintDrawable =
getResources().getDrawable(R.drawable.red_drawable);

        TextView tv = (TextView) findViewById(R.id.textview);

        // setBounds must be called before setCompoundDrawable(), but
it does not matter.
        // this should be a 5 pixel high rectangle the width of the
text.
        paintDrawable.setBounds(0, 0, tv.getWidth(), 5);

        // no matter what you set the bounds to, it becomes the
background of the textview, not underline,
        // which is also there
        // this should put the 5 pixel high rectangle below the text,
which it does, but it also sets the background
        tv.setCompoundDrawables(null, null, null, paintDrawable);

        // this padding seems irrelevant
        tv.setCompoundDrawablePadding(2);
    }
}

And here is how it appears, which I think is highly wrong:

http://www.vonemdeheim.com/picture_library/CompoundDrawablesBug.jpg

Please point out where I made a mistake. Thanks for your attention.


-- 
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

Reply via email to