I have some Buttons
on my android app. They have an icon and text. I can set the background color of a Button
in java code. If the button is clicked I want to display with a different color. So, how do I set a different color for the pressed state of the Button
?
<Button
android:id="@+id/save"
android:layout_width="130dip"
android:layout_height="wrap_content"
android:scaleType="center"
android:drawableTop="@drawable/save"
android:text="Save"
android:textColor="#FFFFFF"
android:textSize="14dip"
>
The onCreate
method:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.homescreen);
save = (Button)findViewById(R.id.save);
save.setBackgroundColor(Color.rgb(27,161,226)); }
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…