/** * 实例化首页订单通知条 */ private TextView getTextView() { // 实例化一个线性布局的参数 LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(0, 12, 0, 0); textView = new TextView(HomeActivity.this); textView.setLayoutParams(lp); textView.setGravity(Gravity.CENTER_VERTICAL); textView.setPadding(30, 0, 30, 0); textView.setTextSize(16); textView.setTextColor(Color.WHITE); textView.setText("通知条"); textView.setMinHeight(120); textView.setBackgroundColor(R.color.Notifi); //#99969696 LinNotifi.addView(textView, lp); Drawable drawable = getResources().getDrawable(R.drawable.laba); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); // 设置边界 textView.setCompoundDrawablePadding(20);// 设置喇叭与textview的距离 textView.setCompoundDrawables(drawable, null, null, null); return textView; }#99969696