如下所示,但它不起作用。如果我将可绘制颜色切换为蓝色,则可以正常工作。
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
<item android:drawable="@android:color/transparent"/>
</ripple>
答案 0 :(得分:82)
添加面具是必要的:
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
<item android:id="@android:id/mask">
<color android:color="@android:color/white" />
</item>
</ripple>
答案 1 :(得分:2)
不知何故,@ JMPergar的回答对我不起作用。
然而,我能够想到这个解决方法:如果透明按钮后面的颜色是实心的(不是渐变或有斑点的图片) - 您可以将该颜色用作主按钮的未按下颜色。
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'register-form',
//'enableClientValidation'=>true,
'enableAjaxValidation' => true,
'clientOptions' => array(
//'validateOnSubmit' => true,
'validateOnChange' => true
),
'action' => array('site/Register'),
));
?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<div class="row">
<?php echo $form->labelEx($model, 'first_name'); ?>
<?php echo $form->textField($model, 'first_name'); ?>
<?php echo $form->error($model, 'first_name'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'last_name'); ?>
<?php echo $form->textField($model, 'last_name'); ?>
<?php echo $form->error($model, 'last_name'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'email'); ?>
<?php echo $form->emailField($model, 'email'); ?>
<?php echo $form->error($model, 'email'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'password'); ?>
<?php echo $form->textField($model, 'password'); ?>
<?php echo $form->error($model, 'password'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'Repeat password'); ?>
<?php echo $form->textField($model, 'repeat_password'); ?>
<?php echo $form->error($model, 'repeat_password'); ?>
</div>
<div>
<?php echo $form->textField($model, 'verifyCode'); ?>
<?php $this->widget('CCaptcha'); ?>
<?php echo $form->error($model, 'verifyCode'); ?>
</div>
<div class="row buttons">
<?php
echo CHtml::ajaxSubmitButton('Register', $this->createUrl("/Site/Register"), array(
'type' => 'POST',
'dataType' => 'json',
'success' => 'js:function(data){
if(data == 1){
window.location ="' . $this->createUrl('site/index') . '"
}
}',
));
?>
</div>
<?php $this->endWidget(); ?>
其中<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/profile_transparent_button_pressed"
>
<item>
<shape>
<corners android:radius="@dimen/profile_transparent_button_corner_radius" />
<solid android:color="@color/profile_background" />
</shape>
</item>
</ripple>
是突出显示按钮的颜色,@color/profile_transparent_button_pressed
- 此按钮后面的布局颜色。它完全符合预期,但仍然是一个解决方法,所以你先尝试@JMPergar的答案。