Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
背景に色状態リストを使用するには? 知っandroid:background="@drawable/drawable_selector"ていandroid:background="@color/color_selector"ますが、例外が発生します。しかし、android:background="#FFFFFF"再び機能します。誰かが理由を説明できますか?
android:background="@drawable/drawable_selector"
android:background="@color/color_selector"
android:background="#FFFFFF"
レイアウトが押されたときにレイアウトの背景色(ドローアブルではない)を変更したいのですが、どうすればよいですか?
色を #FFFFFF のように res/values/colors.xml に入れ、drawable ディレクトリに drawable xml を作成します。
動的にこのように変更できます。役に立つ場合はこれを使用してください - textView.setBackgroundColor(Color.parseColor(getResources().getString(R.string.red)));