android textview中添加图片 挺有意思


    feedbackPhoneTextView = (TextView) findViewById(R.id.feedback_phone_tv);
    ImageGetter imageGetter = new ImageGetter() {
        @Override
        public Drawable getDrawable(String source) {
            int id = Integer.parseIn`在此输入代码`t(source);

            // 根据id从资源文件中获取图片对象
            Drawable d = getResources().getDrawable(id);
            d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
            return d;
        }
    };
    feedbackPhoneTextView.append(Html.fromHtml("<img src=\"" + R.drawable.ic_header_back + "\">", imageGetter, null));

你可能感兴趣的:(android textview中添加图片 挺有意思)