有没有办法以编程方式更改按钮的颜色,或至少更改按钮标签的颜色?我可以改变标签本身
document.getElementById("button").object.textElement.innerText = "newlabel";
Run Code Online (Sandbox Code Playgroud)
但是如何改变颜色呢?
目前我有以下jQuery UI按钮:
$('#button').button(
{
label: 'Test',
icons: {primary: 'ui-icon-circle-plus', secondary: null}
}
);
Run Code Online (Sandbox Code Playgroud)
我希望将自己的图像用于名为'custom.png'的按钮.
我怎么能做到这一点?
我在android中开始编程,我在一个活动中有3个按钮.
我看到一些示例代码将相同的OnClick事件分配给所有按钮(即使它们执行完全不同的操作),并且在方法Switch(id)案例中...
什么是更好的方法?一个onClick方法和切换或许多方法,每个按钮一个?
谢谢.
按钮选择器允许为按钮的每个状态定义背景,但是如何为每个状态定义按钮的文本样式?我的目标是在禁用时使按钮变灰.所以我为按钮的禁用状态设置了一个灰色的背景,但我发现灰色文本的唯一方法是在禁用按钮时动态更改它的颜色...
有人可以帮忙吗?
谢谢
<style name="srp_button" parent="@android:style/Widget.Button">
<item name="android:background">@drawable/btn_default</item>
<item name="android:textColor">#ffffff</item> <!-- How to specify different color for different state? -->
<!-- more stuff -->
</style>
Run Code Online (Sandbox Code Playgroud)
绘制/ btn_default.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true"><shape>
<solid android:color="@color/pink" />
<corners android:radius="6dp" />
</shape></item>
<item><shape>
<solid android:color="#000000" />
<corners android:radius="6dp" />
</shape></item>
</selector>
Run Code Online (Sandbox Code Playgroud) 我想在android中使用不同透明度级别的按钮.我使用过"@android:color/transparent".但它使按钮100%透明.我需要一个70%的透明按钮.这是我正在处理的XML代码:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1">
<Button android:id="@+id/one"
android:text="@string/dtmf_1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textColor="@color/white" ></Button>
<Button android:id="@+id/two"
android:text="@string/dtmf_2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textColor="@color/white" ></Button>
<Button android:id="@+id/three"
android:text="@string/dtmf_3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textColor="@color/white" ></Button>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我需要将按钮的文本设置为just ?.
我很高兴通过Java来做,但宁愿通过XML来做.
可能吗?
我试过了android:text="?" ,android:text="?"但它没有用.
然后我将其中一个字符串资源设置为?,当它不起作用时,我将其设置为?引用,但它不起作用!
如何将按钮标题设置为?使用XML?
有人知道如何轻松实现带有两个拉伸按钮的操作栏吗?
以下是Google日历应用的示例:

谢谢!
我正在制作一个Android应用程序,我有一个通向消息传递位置的按钮.在使用按钮的活动中,我检查是否有任何未读消息,如果是,我想对按钮做一些事情让用户知道有些东西未读.
我想让按钮sorta水平振动,每2或3秒3次震动.
我知道如何在后台运行一个每隔x毫秒做一次的线程.但我不知道该做什么是水平摇动3次.
有人能帮忙吗?
我正在考虑使用sin函数,对于动画,我可以使用sin函数的输出来获取上下的值,我可以设置按钮的水平位置......但这似乎太极端了,是还有更好的方法吗?
谢谢.
我创建了一个按钮,并设置了背景颜色和文本颜色,如下所示.我的问题是:如何设置按钮边框颜色?我想将边框颜色设置为白色
这是我的按钮 res -> layout -> main_nav.xml
<Button
android:id="@+id/btn_emergency"
style="@style/buttonStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Contact and Emergency"
android:onClick="onClickHandleStates" />
Run Code Online (Sandbox Code Playgroud)
这是它的相关风格res -> values -> styles.前两个"项目"自行工作正常.最后的"项目"是我尝试将按钮边框更改为白色而没有成功.
<!-- The button styles -->
<style name="buttonStyle">
<item name="android:textColor">#ffffff</item>
<item name="android:background">#80000000</item>
<item name="android:button">
<shape
android:shape="rectangle" >
<stroke
android:width="0.5dp"
android:color="#ffffff" />
</shape>
</item>
</style>
Run Code Online (Sandbox Code Playgroud)