如何实现Android buttton按钮美化?请大家帮帮我
以下是源代码,那个button按钮怎么美化呢?,请大家帮帮我吧。
比方说如何让button按钮有按下的效果,如何让button按钮实现颜色的渐变。
- Java code
package com.edu.ytu.cn;import android.app.Activity;import android.app.AlertDialog;import android.app.AlertDialog.Builder;import android.content.Intent;import android.os.Bundle;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.view.Window;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.EditText;import android.widget.ImageButton;import android.widget.TextView;import android.widget.Toast;public class MyLoginActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE);//设置窗口无标题 setContentView(R.layout.login); final EditText username_et = (EditText) findViewById(R.id.username_edit); final EditText password_et = (EditText) findViewById(R.id.password_edit); final TextView regist_tv = (TextView) findViewById(R.id.register_link); Button log_bt = (Button) findViewById(R.id.signin_button); log_bt.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final String username_str = username_et.getText().toString(); final String password_str = password_et.getText().toString(); // TODO Auto-generated method stub if(username_str.equals("admin") && password_str.equals("123")){ Intent intent = new Intent(MyLoginActivity.this, MenuActivity.class); startActivity(intent); } else{ Toast.makeText(MyLoginActivity.this, "账号或密码错误,请重新输入!",Toast.LENGTH_SHORT).show(); } } }); regist_tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.regist, (ViewGroup) findViewById(R.id.rg_dialog)); AlertDialog.Builder builder = new Builder(MyLoginActivity.this); builder.setTitle("请认真填写您的信息") .setView(layout) .setPositiveButton("注册", null) .setNegativeButton("取消", null).show(); } }); }}
大家一定要帮帮我呀,谢谢大家了。
[解决办法]
参考这里:
http://blog.csdn.net/aminfo/article/details/7782253
[解决办法]
为不同状态的ICON写布局 (默认/聚焦/按下)
[解决办法]
让UI做美丽些。