I followed Android recommendation and set style="?android:attr/buttonBarStyle" to parent layout and style="?android:attr/buttonBarButtonStyle" to buttons.

So now my layout is something like this:

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="horizontal"

style="?android:attr/buttonBarStyle">

android:id="@+id/button1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Button 1"

style="?android:attr/buttonBarButtonStyle"/>

android:id="@+id/button2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Button 2"

style="?android:attr/buttonBarButtonStyle"/>

android:id="@+id/button3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Button 3"

style="?android:attr/buttonBarButtonStyle"/>

But after setting the style, these buttons have become invisible, although I can still click on them.

Please tell me what is wrong.

Edit: Additional details

Well, I've just created a new project specifically to test this layout and surprisingly it indeed does work.

So to be more precise, actually, I dynamically add this layout to another one, something like this:

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical">

android:id="@+id/buttons_panel_container"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="horizontal">

Code:

LayoutInflater layoutInflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

LinearLayout buttonsPanelContainer = (LinearLayout) findViewById(R.id.buttons_panel_container);

View buttonPanelView = null;

if(chosenValueType.equals("some_type")) {

buttonPanelView = layoutInflater.inflate(R.layout.some_buttons_panel, null);

Button Button1 = (Button) buttonPanelView.findViewById(R.id.button1);

Button1.setOnClickListener(this);

Button Button2 = (Button) buttonPanelView.findViewById(R.id.button2);

Button2.setOnClickListener(this);

} else if (chosenRawValueType.equals("another_type") {

//...

ViewGroup insertPoint = (ViewGroup) buttonsPanelContainer;

insertPoint.addView(buttonPanelView, 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

Sorry to not mention it earlier, I didn't think it could be the case.

So what's wrong?

style=@android:style/buttonbar,Setting style=?android:attr/buttonBarStyle to parent layout and s...相关推荐

  1. 【Android UI】theme style

    背景 最近在整一个前辈留下的老代码,里面有个自定义弹窗dialog, 然后自定义了一个Theme,有点看不懂,并且不用这个Theme 整个窗口弹出就出问题了. 回忆theme style 的区别和作用 ...

  2. android导入项目出现style错误,menu错误

    android导入项目出现style错误,menu错误 style //查看 res/values/styles.xml 下的报错点.<style name="AppBaseTheme ...

  3. android UI进阶之style和theme的使用

    今天来和大家分享一下android中UI设计里面常会用到的style和theme. 首先,style和theme都是资源,android提供了很多这样的默认资源.你可以来使用它们.同时你也可以自己定义 ...

  4. Android将ButtonBar放在屏幕底部

    ButtonBar的方式写底部button,试了试,看起来外观貌似比Tab好看,不过恐怕没有Tab管理Activity方便吧,毕竟一个Tab就是一个Activity,但是这样用Button的话,却并不 ...

  5. android wifi热点setting

    目录 一.wifi原生setting的入口在WifiTetherSettings.java 二.改热点Setting的时候可以直接只编译Settings.apk,并且替换, 三.wifi热点貌似官方支 ...

  6. 【Neural Style Transfer】 Fast Neural Style

    上周写了深度学习与艺术--画风迁移 Neural Style的文章,这周就来聊一聊Fast Neural Style,从名字可以看出,Fast Neural Style的最大的特色就是快,也就是说如果 ...

  7. 菜鸟学Android源码——Setting(1)

    菜鸟学Android源码--Setting(1) 在上一篇中,我简单介绍了Android源码的下载和编译,还没有下载编译源码的小伙伴请看这里:Android源码分析之--下载并编译源码 关于系统设置A ...

  8. UIElements开发人员指南9 样式(Style)和Unity样式表(style sheets)

    样式(Style)和Unity样式表(style sheets) 每个VisualElement都包含样式属性,用于设置元素的尺寸以及元素在屏幕上的绘制方式,例如backgroundColor或bor ...

  9. 全面的Android studio的setting设置,

    有时候,需要,需要去设置一些东西,,这个比较全面,记录一下,下次就直接找 Android  studio  的setting的配置. https://blog.csdn.net/m0_37711172 ...

最新文章

  1. 微信小程序-控制文本只显示若干行多余隐藏
  2. electron调试html,electron桌面应用程序开发入门
  3. 一元流量参数为null_为什么牛逼的程序员都不用 “ ! = null quot; 做判空?
  4. vs2012搭建gtest环境
  5. mysql010函数使用.单行函数.多行函数
  6. linux 环境安装DBI和DBD_03
  7. python opencv最小外接矩形中心点_Opencv绘制最小外接矩形、最小外接圆
  8. mimemultipart java_H5提交MIME类型为multipart/form-data类型的表单,后端如何处理(比如java,.NET)?...
  9. myPassword
  10. Linux安装Diamond软件,Diamond软件比对蛋白质数据库
  11. COMSOL:案列应用实操教学---光电
  12. centos 测试get请求_centos网速测试
  13. Python学习笔记-数据分析-Pandas02-Dataframe
  14. 线性系统粗浅认识——第七次作业
  15. 直方图归一化因子计算公式
  16. 素问·金匮真言论原文
  17. steam进社区显示服务器错误,Steam社区显示102错误代码怎么办?为什么不能打开Steam社区?...
  18. 安装caffe依赖库时,出现“您希望继续执行吗? [Y/n] y 中止。”的解决办法
  19. 中断优先级分组与抢占优先级和响应优先级的关系
  20. Oracle——2.查询基本语法

热门文章

  1. UITableView中selectRowAtIndexPath: animated:scrollPosition滚动到指定Row
  2. BinaryReader 、BinaryWriter是方便用二进制方式读写int,double,string之类的数据
  3. 用defy来潜水最终还是挂了........
  4. 系统管理员易犯错误及解决方法汇总
  5. 把window中换行符(^M)改为linux的换行符(\r)
  6. java singleton 多线程_Java创建线程安全的单例singleton
  7. mysql删除重复文章标题_MySQL中查询、删除重复记录的方法大全
  8. Java删除文件夹和文件
  9. JSP怎么将表单提交到对应的servlet
  10. 动态添加综合布局---动态添加控件及将某XML动态加入到Activity显示(续)