我是使用pixate的新手,所以如果我的问题听起来很天真,我很抱歉
我想设置一个按钮,我创建了一个Activity并在我的assets文件夹中添加了css,但按钮中没有任何变化。
MainActivity
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Pixate.init(this);
setContentView(R.layout.activity_main);
Button b = (Button) findViewById(R.id.button1);
Pixate.setStyle(b, "button.css");
}
button.css
#button1 {
background-color: linear-gradient(#FF679B,#394170);
height: 44px;
border-radius : 5px;
border-width : 1px;
border-color : #444;
}
答案 0 :(得分:1)
将样式放在资源下的default.css
文件中(不会加载任何其他文件名)。在那之后,你几乎没有打电话给setStyle
(在那种情况下你不需要那个)。
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Pixate.init(this);
setContentView(R.layout.activity_main);
// No need to get a hold of the button. Pixate init will capture it.
// Just make sure you have set the id in the XML layout to "button1"
// Button b = (Button) findViewById(R.id.button1);
}
[ADDITION] 另请注意上面的评论并查看http://www.pixate.com/blog/2013-10-30-android-button-demo/上的博文,了解如何设置按钮状态的样式。 Pixate是一个开源项目,因此您可以从https://github.com/Pixate/pixate-freestyle-android获取库(它包含几个示例项目以帮助您入门)