莫为难 2016-03-16 06:23 采纳率: 0%
浏览 1375

关于动态修改布局背景

我有个布局如下:

android:layout_width="match_parent"
android:layout_height="55dp"
android:background="@color/base_color_text_black"
android:baselineAligned="false"
android:orientation="horizontal" >

<LinearLayout
    android:id="@+id/id_main_pager"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:clickable="true"
    android:gravity="center"
    android:onClick="onMainPager"
    android:orientation="vertical" >

    <ImageButton
        android:id="@+id/id_main_pager_img"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:clickable="false"
        android:contentDescription="@string/app_name"
        android:src="@drawable/bottom_main_pager_an" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/main_pager" />
</LinearLayout>
    ...............

现在想动态的修改这个布局的背景颜色:
代码如下:
View in = LayoutInflater.from(this).inflate(R.layout.bottom, null);
in.setBackgroundColor(Color.BLUE);

为何设置的颜色不起效呢?有高手能指点下吗??????

  • 写回答

1条回答

  • bdmh 移动开发领域优质创作者 2016-03-16 06:27
    关注

    应该是被其他元素覆盖住了吧

    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧