对于默认的android按钮,当我点击它时,它的颜色会变为橙色几秒钟(用于通知用户点击该按钮).无论如何,我不想要这个属性.我不想改变我的按钮颜色.如何禁用此属性?
默认情况下,单击按钮时,橙色等颜色会短时间环绕按钮,表示单击了按钮.但是当按钮包含背景图像时,此功能无效.这也发生在列表视图中.为什么?有任何想法吗?TIA
我使用了setBackgroundColor(Color.BLUE); 但这里应用的颜色并没有消失......
我创建了自己的按钮
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
...></ImageView>
<ImageView
...></ImageView>
<TextView
...></TextView>
</merge>
Run Code Online (Sandbox Code Playgroud)
她是我的Button的班级
public class StandardButton extends RelativeLayout implements OnClickListener{
...
private void init(Context context){
this.setClickable(true);
this.setEnabled(true);
this.setFocusable(true);
this.setFocusableInTouchMode(true);
LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.standard_button, this);
}
@Override
public void onClick(View v) {
setLabel("Click");
}
Run Code Online (Sandbox Code Playgroud)
onClick函数不起作用.但是如果我把Button放在我的Activity中,它会覆盖onClick函数.
在我的StandardButton类中单击Button时是否有触发函数的解决方案.这个班级应该知道它是否被点击,而不是活动!
for pic,fn,xoff in [(self.PNew,self.New,0),(self.POpen,self.Open,0),(self.PSave,self.Save,0),(self.POrigin,self.SetOrigin,20),(self.PFiducial,self.SetFiducial,0),(self.PLine,self.AddLine,20),(self.PPoint,self.AddPoint,0),(self.PMove,self.AddMove,0),(self.PCircle,self.AddCircle,0),(self.PCall,self.AddCall,0)]: Button(ButtonRow,image=pic,command=fn).pack(side=LEFT,padx=(xoff,0))
Run Code Online (Sandbox Code Playgroud) 我有一个JQuery Button,默认情况下禁用,我需要在某些事件上启用它.
我的问题是,当我只是删除属性'disabled'时,按钮会保持禁用的jquery css样式.
我手工删除它们:
$('[id$=btnDowloadXLS]').removeAttr("disabled").removeClass("ui-state-disabled").removeClass("ui-button-disabled");
Run Code Online (Sandbox Code Playgroud)
但是,然后按钮与活动按钮不同,onMouseDown它没有采取正确的样式.
我想出了这个解决方案
$('[id$=btnDowloadXLS]').button({ disabled: false });
Run Code Online (Sandbox Code Playgroud)
我认为再次创建 JQuery按钮.
我的问题是:是否有更清晰,正确的方法来重新启用按钮,并且该按钮获得正确/默认启用的样式?
我需要知道是否可以从另一个按钮中调用Click of a按钮.
private void myAction_Click(object sender, EventArgs e)
{
// int x;
// ...
}
private void Go_Click(object sender, EventArgs e)
{
// call the myAction_Click button
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
这是我的形状
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#80000000"
android:endColor="#80FFFFFF"
android:angle="45"/>
<padding android:left="7dp"
android:top="7dp"
android:right="7dp"
android:bottom="7dp" />
<corners android:radius="10dp" />
</shape>
Run Code Online (Sandbox Code Playgroud)
这就是我按下按钮所需要的
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#80FFFFFF"
android:endColor="#80000000"
android:angle="45"/>
<padding android:left="7dp"
android:top="7dp"
android:right="7dp"
android:bottom="7dp" />
<corners android:radius="10dp" />
</shape>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/button_pressed" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/button_focused" /> <!-- focused -->
<item android:drawable="@drawable/button_normal" /> <!-- default -->
</selector>
Run Code Online (Sandbox Code Playgroud)
我尝试将此代码链接到两个形状但是当我将其设置为背景时,它只是使我的按钮默认为灰色.
并且我将选择器添加到我的按钮的背景中,它具有正确的不透明度,但我需要它在单击时显示不同的颜色(如白色或其他东西).
有谁有想法吗?
所以我想让我的按钮有白色边缘/黑色背景边框,有没有一个简单的解决方案在我的xml中执行此操作?
<input type="submit" value="Go!"/>
Run Code Online (Sandbox Code Playgroud)
给出一个这样的按钮:

我希望按钮跨越页面的整个宽度.我怎样才能做到这一点?
在我的WPF应用程序中,我有几个按钮作为菜单.
这种情况类似于网站中的菜单.
当我单击其中一个按钮时,我希望该按钮样式与其他按钮样式不同,当我选择另一个按钮样式时,前一个应该是正常的,并且选定的样式应该应用于此选定按钮.
你能告诉我如何通过ControlTemplate实现这一目标,还是必须维护一个让我们知道选择了哪个按钮的IsSelected属性?
谢谢,
VJ