2.然后找到控件,设置点击监听跳转界面
mBtnButton = findViewById(R.id.btn_button); mBtnButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //跳转到Button演示界面 Intent intent = new Intent(MainActivity. this,ButtonActivity. class);//跳转到 startActivity(intent); }}) 1.自定义button的背景形状 1.1圆角矩形 在drawabe中new一个drawable resources file 起个名字,填好root element(这里我们使用shape) <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#ff9900" /> <corners android:radius="20dp"/> //还有许多其他属性自行百度 </shape> 2.自定义button的按压效果 3.点击事件1.1
