1.基础button代码:
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="第一个按钮"
android:textSize="30sp"
android:textColor="#0033FF"
android:background="#C7F709"
android:foreground="?selectableItemBackground"
android:layout_marginTop="25dp"
android:layout_marginHorizontal="35dp"
/>
水波纹效果:
android:foreground="?selectableItemBackground"
2.两个按钮垂直显示:
android:orientation="vertical"
3.按钮点击事件模板
Button1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
//跳转
Intent intent = new Intent(MainActivity.this,loading_Activity.class);
startActivity(intent);
}
});
4.页面跳转
//跳转
Intent intent = new Intent(MainActivity.this,loading_Activity.class);
startActivity(intent);
5.toast提示
Toast.makeText(MainActivity.this,"欢迎进入",Toast.LENGTH_SHORT).show();
6.按钮的点击效果和圆角设计:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<solid android:color="#0099CC"/>
<corners android:radius="15dp"/>
</shape>
</item>
<item android:state_pressed="false">
<shape>
<solid android:color="#99CCFF"/>
<corners android:radius="15dp"/>
</shape>
</item>
</selector>