문제

I am new to using pixate so I am sorry if my question sounds naive

I want to style a button ,I have created an Activity and added css in my assets folder but still there is no change in the button.

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;
}
도움이 되었습니까?

해결책

Place your styling in a default.css file under your assets (any other file name will not load). After that, you are pretty much set without calling the setStyle (you don't need that in that context).

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] Also note the comment above and check out the blog post at http://www.pixate.com/blog/2013-10-30-android-button-demo/ to see how to style the button's states. Pixate is an open-source project, so you can grab the library from https://github.com/Pixate/pixate-freestyle-android (it contains a couple of sample projects to help you get started)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top