zoukankan      html  css  js  c++  java
  • android 怎么动态设置button 的style

    网上找了很多,还是没有直接的解决办法,button没有setstyle这个方法。因此我的解决办法如下:

    直接动态设置各个属性

    Button themeBtn = new Button(this);
                themeBtn.setText(entry.getKey());
                LayoutParams lparams = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.MATCH_PARENT);
                themeBtn.setLayoutParams(lparams);
                themeBtn.setTextAppearance(this, R.style.ImageCategoryThemeBtn);
                themeBtn.setPadding(DensityUtils.dp2px(this, 8), 0, DensityUtils.dp2px(this, 8), 0);
                themeBtn.setBackgroundResource(R.drawable.selector_bt_gray2blue);
                v_theme.addView(themeBtn);

    style:

    <style name="ImageCategoryThemeBtn" parent="@android:style/Widget.Button">
            <item name="android:textColor">@color/image_theme</item>
            <item name="android:textSize">@dimen/imageThemeBtnTextSize</item>
        </style>
  • 相关阅读:
    设置内存管理
    Kill Session
    设置In_Memery
    查询无效对象 及 重新编译
    Oracle 硬解析查询
    设置Oracle 12C OEM 端口
    创建Mysql 序列
    compress 表设置及索引设置
    闪回表
    ECS Samples概述
  • 原文地址:https://www.cnblogs.com/feijian/p/4531333.html
Copyright © 2011-2022 走看看