スナックバーのアクション ボタンの背景色を変更したり、非表示 (灰色の背景) にしたりするにはどうすればよいですか?
私はこのコードを使用します:
Snackbar mysnack = Snackbar.make(main_layout, getResources().getString(R.string.snack_1), 5000);
View view = mysnack.getView();
TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_text);
tv.setTextColor(getResources().getColor(R.color.text_light));
mysnack.setActionTextColor(getResources().getColor(R.color.text_light));
mysnack.setAction("RATE", new View.OnClickListener() {
@Override
public void onClick(View view) {
Uri uri = Uri.parse(getResources().getString(R.string.snack_url));
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});
TypedValue typedValue = new TypedValue();
getTheme().resolveAttribute(R.attr.colorPrimaryDark, typedValue, true);
final int color = typedValue.data;
mysnack.getView().setBackgroundColor(color);
mysnack.show();
私の質問は重複していません。テキストの色ではなく、背景の色を求めます。最初に読み、次に理解し、次に考え、次に誰かの質問が重複していることを書くことにします。