Can you please tell me how can I place an background image to a the left upper corner of TextView in android? I would like the image not to be scaled by android.
I have tried
Resources res = getResources(); setCompoundDrawables(res.getDrawable(R.drawable.icon48x48_1), null, null, null);
Nothing is shown.
And I have tried set开发者_JAVA技巧Background(R.drawable.icon48x48_1);
But it stretches the image.
Thank you for any help.
Have you tried setting the DrawableLeft in you xml layout of the textview?
android:drawableLeft="@+id/img">
You could always make your new background image a 9-patch and put the stretchable areas on the right and bottom in a transparent area.
This is really a dirty hack so use it only as your last resource.
If this is what you want

you can do something like
    final TextView tv = (TextView) findViewById(R.id.TextView01);
    tv.setTransformationMethod(new TransformationMethod() {
        private static final String INDENT = "       ";
        @Override
        public void onFocusChanged(View view, CharSequence sourceText,
                boolean focused, int direction, Rect previouslyFocusedRect) {
            // TODO Auto-generated method stub
        }
        @Override
        public CharSequence getTransformation(CharSequence source, View view) {
            return INDENT + source;
        }
    });
using a FrameLayout containing both the ImageView and TextView.
Notice that if the icon spans more than one line it's not going to work.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论