跳至主要内容

博文

目前显示的是标签为“button”的博文

android Button add ripple effects

Method 1:  To Add Ripple Effect/Animation to a Android Button Just replace your button background attribute with  android:background="?attr/selectableItemBackground"  and your code looks like this. < Button android : layout_width = " match_parent " android : layout_height = " wrap_content " android : background = " ?attr/selectableItemBackground " android : text = " Click Me " /> view raw button_ripple_effect.xml  hosted with ❤ by  GitHub Method 2:  To Add Ripple Effect/Animation to a Android Button Using this method, you can customize ripple effect color. First, you have to create a xml file in your drawable resource directory. Create a  ripple_effect.xml  file and add following code. res/drawable/ripple_effect.xml <? xml version = " 1.0 " encoding = " utf-8 " ?> < ripple xmlns : android = " http://schemas.android.com/apk/res/andr...

android fab button

gradle file: compile 'com.android.support:appcompat-v7:25.2.0' compile 'com.android.support:design:25.2.0' layout.xml <android.support.design.widget.FloatingActionButton android :layout_width= "wrap_content" android :src= "@android:drawable/ic_media_play" android :elevation= "6dp" android :background= "@color/colorAccent" android :layout_margin= "16dp" app :pressedTranslationZ= "12dp" android :layout_height= "wrap_content" /> Theme.AppCompat class extend AppCompatActivity

Android控件系列之RadioButton&RadioGroup

1 TextView tv = null ; // 根据不同选项所要变更的文本控件 2 @Override 3 public void onCreate(Bundle savedInstanceState) { 4 super.onCreate(savedInstanceState); 5 6 setContentView(R.layout.main); 7 8 // 根据ID找到该文本控件 9 tv = (TextView) this .findViewById(R.id.tvSex); 10 // 根据ID找到RadioGroup实例 11 RadioGroup group = (RadioGroup) this .findViewById(R.id.radioGroup); 12 // 绑定一个匿名监听器 13 group.setOnCheckedChangeListener( new OnCheckedChangeListener() { 14 15 @Override 16 public void onCheckedChanged(RadioGroup arg0, int arg1) { 17 // TODO Auto-generated method stub 18 // 获取变更后的选中项的ID 19 int radioButtonId = arg0.getCheckedRadioButtonId(); 20 // 根据ID获取RadioButton的实例 21 RadioButton rb = (RadioButton)MyActiviy. this .findViewById(radioButtonId); 22 // 更新文本内容...