0
A
回答
0
1
對於Android,LinearLayout佈局不帶邊框屬性。但是,您可以將LinearLayout的背景設置爲9補丁圖像。
只要將其鏈接回您的Java文件,您就可以修改您創建的xml文件上的任何內容。
例子: 如果您的XML文件是:
<?xml version="1.0" encoding="utf-8"?>
<!-- note that the id is linearlayout. That's important, you want the id to be something you can use to identify that element. -->
<LinearLayout`
xmlns:android="http://schemas.android.com/apk/res/android"`
android:id="@+id/linearlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</LinearLayout>
然後在你的Java文件,你不得不這樣做:如果你
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.whateverXMLFile);
//get the Linear Layout you're searching for
LinearLayout linLayout = (LinearLayout) findViewById(R.id.linearlayout);
/*background is your background image you want to replace with.
* You can use any that is in your drawable resource.
* Better to use a 9 sketch because it'll expand to fit your width/height, no matter
* how big or small your layout will be.
*/
linLayout.setBackgroundResource(R.drawable.background);
//if you want to set the background colour:
//will set it to RED, you can also specify a resource file you may have for it
linLayout.setBackground(Colour.RED);
}
相關問題
- 1. 受下層線性佈局顏色影響的線性佈局顏色
- 2. 不同顏色的佈局
- 3. 如何設置線性佈局的邊框顏色
- 4. 不同顏色的透明android佈局
- 5. 無法更改佈局邊框顏色
- 6. 邊框顏色
- 7. 邊框顏色
- 8. 顏色代碼的Android不同
- 9. 邊框顏色忽略我的顏色
- 10. JavaScript的邊框顏色/顏色樣式
- 11. 從iphone中刪除紅色邊框顏色佈局
- 12. 漸變顏色在android中的佈局
- 13. Android按鈕邊框顏色
- 14. Android TextView頂部和底部線條/不同顏色的邊框
- 15. cytoscape中不同組邊緣的不同顏色代碼
- 16. 半徑不同顏色的css邊框
- 17. 使用不同顏色的雙邊框
- 18. processing.js RECT()不同的邊框顏色
- 19. 如何更改程序代碼中的EditText邊框線顏色?
- 20. Photoshop顏色邊框黑色
- 21. 更改邊框線和字體顏色的顏色
- 22. 顏色佈局不一致
- 23. 行邊框顏色
- 24. LinkLabel邊框顏色
- 25. ListView邊框顏色
- 26. NSView邊框顏色
- 27. 邊框顏色不變
- 28. CSS屬性邊框顏色不工作
- 29. Android佈局中的填充顏色
- 30. 我可以使用顏色和不同顏色的邊框描邊路徑嗎?
你找到問題的解決方案,發現請分享解決方案 – 2015-02-15 20:58:32