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. 邊框顏色
- 5. 顏色代碼的Android不同
- 6. 從iphone中刪除紅色邊框顏色佈局
- 7. JavaScript的邊框顏色/顏色樣式
- 8. 邊框顏色忽略我的顏色
- 9. processing.js RECT()不同的邊框顏色
- 10. 半徑不同顏色的css邊框
- 11. cytoscape中不同組邊緣的不同顏色代碼
- 12. 如何更改程序代碼中的EditText邊框線顏色?
- 13. LinkLabel邊框顏色
- 14. 行邊框顏色
- 15. ListView邊框顏色
- 16. 邊框顏色不變
- 17. 不同顏色的SSRS邊框線不能正確重疊
- 18. 顏色在曲線分佈下的陰影區域繪製不同的顏色
- 19. 框架邊框顏色
- 20. 帶邊框顏色的RoundedImageview
- 21. WPF SystemColors:TextBox邊框的顏色
- 22. ImageView上邊框的顏色
- 23. 如何在android中分配不同的顏色代碼?
- 24. 顏色繪製不同的顏色matplotlib
- 25. 從兩種佈局顏色
- 26. WPF XAML中邊框各邊的顏色不同?
- 27. 不同顏色
- 28. 具有不同顏色邊框的Android繪製圓圈
- 29. UITableView單面邊框顏色?
- 30. CSS3智能邊框顏色
你找到問題的解決方案,發現請分享解決方案 – 2015-02-15 20:58:32