2014-02-21 28 views
2

我是新來使用pixate樣式的按鈕,所以我很抱歉,如果我的問題聽起來很幼稚如何使用pixate(機器人)

我想要的風格按鈕,我已經創建了一個活動,並在我的資產中添加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

去這裏http://www.pixate.com/blog/2013- 10-30-android-button-demo/ – insomniac

回答

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(它包含了幾個示例項目來幫助你開始)抓取庫

+0

謝謝我會試試 – Prerak

+0

我已將button.css文件重命名爲default.css,並刪除了setstyle語句,但它仍然不起作用 – Prerak

+0

好的,我爲你創建了一個項目,它按預期工作。您可以從https://www.dropbox.com/s/hfu3m9glhm0q58g/PixateButtonTest.zip獲取zip。另外,看起來您使用的是舊版本。現在沒有這樣的類'Pixate'了。它被'PixateFreestyle'取代。你可以從我上面發佈的github repo鏈接中獲取最新版本。然後將其作爲項目導入到您的工作區,並調整我在此處鏈接的項目中的庫路徑。 – sgibly