2012-09-11 99 views
8

過去幾天我一直在玩android應用程序,似乎無法讓我的頭在整個UI和佈局開發周圍。如何將PSD設計轉換爲Android xml?

我在過去的一年中一直使用Java進行編程,所以我對這門語言非常熟悉,而且我已經在CSS前幾年開發了前端,但我似乎可以進行轉換。

如果任何人都可以指向我一些很棒的在線資源。

非常感謝

+0

希望這個幫助http://stackoverflow.com/questions/1377046/how-can-i-make-template-of-blogger-from-psd-fiels-psd-to-xml-file –

+0

我在找更長的Android佈局xml的行,但無論如何感謝。 – user827570

回答

8

這是因爲你做了它的HTML的方式非常簡單。除了必須在xml中編寫CSS之外,所有內容都是相同的。有些東西叫包裝內容,填充父項等。你應該以適當的方式使用它們。檢查你PSD中是否有漸變背景的按鈕,然後切片並使用ImageButton並將切片圖像分配給圖像按鈕。即使是文本,只需獲取顏色,大小......並在XML中尋找可以做到這一點的東西。看看下面的代碼。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:orientation="vertical" > 
    <TextView android:id="@+id/text" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Hello, I am a TextView" /> 
    <Button android:id="@+id/button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Hello, I am a Button" /> 
</LinearLayout> 

LinearLayout將安排其子單列或單行。現在它是一個單列,因爲方向是垂直的。如果你做到了水平,那麼它是一排。同樣,看看RelativeLayout這與HTML中的相對定位類似。要更改背景,您可以使用android:background="color value here"。這裏沒有技術限制。您將獲得填充和邊距。只需從xml佈局開始。通過觀察PSD來做到這一點。我相信你的CSS經驗會搖擺不定。祝一切順利。