Why does android ImageSpan show my picture twice (when setBounds exceed certain magic width)?

后端 未结 1 397
小鲜肉
小鲜肉 2021-01-16 21:11

Here is my code to put an ImageSpan in an EditText.

public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState         


        
1条回答
  •  北荒
    北荒 (楼主)
    2021-01-16 21:43

    this worked for me

    int width;
    int height;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_matn_activity3);  
    Display display = getWindowManager().getDefaultDisplay(); 
         width = display.getWidth();  // deprecated
         height = display.getHeight();  // deprecated
     SpannableString ss = new SpannableString("ABC");
    Drawable d = getResources().getDrawable(R.drawable.ic_launcher);
    double ratio= (double)((double)(d.getIntrinsicWidth())/(double)(d.getIntrinsicHeight()));
    //this shows the original ratio of image
    
                    if(d.getIntrinsicWidth()

    it may have little problems because my project is big and different i cant put the exact code .but it generally works

    0 讨论(0)
提交回复
热议问题