2012-03-21 57 views
6

嗨,你知道是否有捷徑來設置你的佈局文件,有點像CSS。例如 而不是Android:佈局文件邊距/填充快捷鍵

android:layout_marginTop="20dp" 
android:layout_marginLeft="20dp" 
android:layout_marginBottom="10dp" 
android:layout_marginRight="5dp" 

也許是這樣嗎?

android:layout_margin="20dp, 20dp, 10dp, 5dp" 

同樣將是填充/半徑等..

如果你想要爲所有方設置相同的值,那麼你可以使用這樣

回答

8

android:layout_margin="20dp" 

,如果您有對於所有方面不同的價值,那麼你必須以這種方式設置它們:

android:layout_marginTop="20dp" 
android:layout_marginLeft="20dp" 
android:layout_marginBottom="10dp" 
android:layout_marginRight="5dp" 

和填充相同的東西。

+1

它確實看起來像這可能是在編程上可能的。在我不得不承認的android的xml有點傻。 – Purplemonkey 2012-03-31 07:49:49