This question already has answers here:
Is there an easy way to strike through text in an app widget?
                                
                                    (17个答案)
                                
                        
                                3年前关闭。
            
                    
试图建立一个购物车,想要显示折扣价,而对于旧价格,则要如图所示

android - 如何使文本 View 完全像这样-LMLPHP

最佳答案

做这个:

   TextView someTextView = (TextView) findViewById(R.id.some_text_view);
   someTextView.setText(someString); // SomeString = your old price
   someTextView.setPaintFlags(someTextView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

10-07 12:17