我是 pixate 的新手,如果我的问题听起来很幼稚,我很抱歉
我想为按钮设置样式,我已经创建了一个 Activity 并在我的 Assets 文件夹中添加了 css,但按钮中仍然没有任何变化。
主要 Activity
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");
}
按钮.css
#button1 {
background-color: linear-gradient(#FF679B,#394170);
height: 44px;
border-radius : 5px;
border-width : 1px;
border-color : #444;
}
最佳答案
将您的样式放在 Assets 下的 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);
}
[添加] 另请注意上面的评论并查看博客文章 http://www.pixate.com/blog/2013-10-30-android-button-demo/查看如何设置按钮状态的样式。 Pixate 是一个开源元素,因此您可以从 https://github.com/Pixate/pixate-freestyle-android 获取库。 (它包含几个示例元素来帮助您入门)
关于android - 如何使用 pixate (android) 设置按钮样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21928717/