首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android如何获取样式“style=”@android: LinearLayout /ButtonBar“”

Android如何获取样式“style=”@android: LinearLayout /ButtonBar“”
EN

Stack Overflow用户
提问于 2012-03-25 06:23:50
回答 2查看 2.6K关注 0票数 2

我想以编程方式获得样式为'ButtonBar‘的LinearLayout的背景色。

代码语言:javascript
复制
<LinearLayout
    android:id="@+id/buttonBar"
    style="@android:style/ButtonBar"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

我尝试使用LinearLayout的getBackgroundColor,但没有找到方法。

有谁有主意吗?问候

EN

回答 2

Stack Overflow用户

发布于 2012-03-25 06:40:19

试试这个:

代码语言:javascript
复制
LinearLayout layout = (LinearLayout)findViewById(R.id.buttonBar);

PaintDrawable d = (PaintDrawable)layout.getBackground();
Paint paint = d.getPaint();
int color = paint.getColor();
票数 6
EN

Stack Overflow用户

发布于 2012-12-13 19:27:59

代码语言:javascript
复制
style="@android:style/ButtonBar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" 
android:background="#CCCC99">
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9856155

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档