2011-03-21 104 views
1

我用下面的代码错误定制吐司消息

public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 


     TextView textView = new TextView(this); 
     textView.setBackgroundColor(Color.YELLOW); 
     textView.setTextColor(Color.WHITE); 
     textView.setPadding(10, 10, 10, 10); 
     textView.setText("Textview as Toast"); 

     Toast toastView = new Toast(this); 
     toastView.setView(textView); 
     toastView.setDuration(Toast.LENGTH_LONG); 
     toastView.setGravity(Gravity.CENTER, 0, 0); 
     toastView.show(); 

    } 

我现在面临的问题是,当我加入我自己的背景色为TextView的,它没有采取定制吐司消息。它采用Color类中定义的颜色。

请提供您的意见和建议。

+0

如果你改变文字颜色,是否需要? – trgraglia 2011-03-21 10:13:26

回答

1

试着通过你的颜色像这样0xff888888格式

+0

在color.xml中定义#BA862B然后添加为textView.setBackgroundColor(R.color.orange); – chiranjib 2011-03-21 10:21:59