我试图样式材料EditText
视图:
<style name="AppTheme.EditText" parent="@style/Widget.AppCompat.EditText">
<item name="android:textColor">@color/white</item>
<item name="android:textColorHint">#8AFFFFFF</item>
<item name="colorControlNormal">@color/white</item>
<item name="colorControlActivated">@color/white</item>
<item name="colorControlHighlight">@color/white</item>
</style>
然后在我的主题上应用样式:
<style name="AppTheme">
<item name="editTextStyle">@style/AppTheme.EditText</item>
</style>
并将主题应用于活动:
<activity
android:name=".MyActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="stateAlwaysHidden"
android:theme="@style/AppTheme">
然而,这并没有改变下划线的颜色。
我知道我可以更改accentColor来更改下划线颜色,但我不想这样做,因为我需要我的accentColor与其他一些控件的颜色不同。
我可以这样设置控件下划线颜色的样式吗?
这个解决方案对我来说是有效的。sIt只是在编辑文本样式主题中覆盖colControlActivated
,colControlHighlight
和colControlStandard
的值。其他的想法是,如果你想改变光标的颜色也然后android: text CursorDrawable
使用这个属性。我也把这个编辑文本样式放在style.xml(v21)
中。然后,考虑在你想要的任何活动中使用这个主题。下面是一个例子:
第一个解决方案
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<!--Edittext theme -->
<item name="editTextStyle">@style/App_EditTextStyle</item>
</style>
<style name="App_EditTextStyle" parent="@style/Widget.AppCompat.EditText">
<item name="android:textColor">@color/white</item>
<item name="android:textColorHint">@color/black</item>
<item name="colorControlNormal">@color/white</item>
<item name="colorControlActivated">@color/white</item>
<item name="colorControlHighlight">@color/white</item>
<item name="android:backgroundTint" >@color/white</item>
<item name="backgroundTint">@color/white</item>
<item name="android:textCursorDrawable">@color/white</item>
</style>
其他解决方案
您也可以通过编程方式进行设置。下面是API的解决方案
Drawable drawable = yourEditText.getBackground(); // get current EditText drawable
drawable.setColorFilter(Color.GREEN, PorterDuff.Mode.SRC_ATOP); // change the drawable color
if(Build.VERSION.SDK_INT > 16) {
yourEditText.setBackground(drawable); // set the new drawable to EditText
}else{
yourEditText.setBackgroundDrawable(drawable); // use setBackgroundDrawable because setBackground required API 16
}
在这里,你只需按照以下步骤,你就完成了。
步骤1:创建样式
将android:textCursorDrawable
属性设置为@null将导致使用android:textColor
作为光标颜色。
<style name="editTextTheme" parent="@style/Widget.AppCompat.EditText">
<item name="android:textColorHint">@color/white</item>
<item name="colorControlNormal">@color/white</item>
<item name="colorControlActivated">@color/white</item>
<item name="colorControlHighlight">@color/white</item>
<item name="colorAccent">@color/white</item>
<item name="android:textCursorDrawable">@null</item>
<item name="android:textColorPrimary">@color/white</item>
</style>
第2步:将该样式用作主题
<style name="MyTheme">
<item name="theme">@style/editTextTheme</item>
</style>
步骤3:在组件中实现该主题
<android.support.v7.widget.AppCompatEditText
android:id="@+id/editText"
style="@style/MyTheme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter Name"
android:inputType="textPersonName" />
不起作用的原因:colorControlNormal
是主题属性,而android:textColor
是样式属性。要更改colorControlNormal
,必须覆盖主题;要更改android:textColor
值,必须覆盖样式。@style/Widget中没有名为
或其任何父项。因此,执行此操作时不覆盖任何内容:colorControlNormal
的属性。AppCompat。EditText
<style name="AppTheme.EditText" parent="@style/Widget.AppCompat.EditText">
<item name="colorControlNormal">@color/white</item>
</style>
解决方案:要实际更改colControlStandard
的值,您必须在主题中更改它。要做到这一点而不改变活动的主题,您可以:
1/创建仅包含要更改的主题属性的主题Overlay:
<style name="AppTheme.EditText">
<item name="colorControlNormal">@color/white</item>
</style>
2/仅在您的EditText
视图中使用:
<EditText
android:layout_width="match_parent"
android:theme="@style/AppTheme.EditText"
/>
这里实际发生的是将使用视图的主题属性(如果存在)。活动的主题将作为后备。
您始终可以更改活动主题的colorControlNormal
,以影响整个活动。
问题内容: 我需要有关在Openpyxl中设置样式的建议。 我看到可以设置单元格的NumberFormat,但是我还需要设置字体颜色和属性(粗体等)。有一个style.py类,但是似乎我无法设置单元格的style属性,而且我真的不想开始修改openpyxl源代码。 有没有人找到解决方案? 问题答案: 从openpyxl版本1.5.7开始,我已成功应用以下工作表样式选项… 仅供参考,您可以在…中找到
在 Rax 中,有以下几种方式给元素设置样式: 内联样式 通过元素的 style 属性,为元素设置内联样式: 1const myStyle = { 2 fontSize: '24px', 3 color: '#FF0000' 4}; 5 6const element = <h1 style={myStyle}>Hello Rax</h1>; 需要注意的是,style 的值是一个 object,
接口说明 设置样式 如需调用,请访问 开发者文档 来查看详细的接口使用说明 该接口仅开放给已获取SDK的开发者 API地址 POST /wish3dearth/api/material/shp/v1.0.0/setStyle 是否需要登录 是 请求字段说明 参数 类型 请求类型 是否必须 说明 token string header 是 当前登录用户的TOKEN sceneId string qu
接口说明 设置样式 如需调用,请访问 开发者文档 来查看详细的接口使用说明 该接口仅开放给已获取SDK的开发者 如开启https功能,请求地址的协议应改为https,如:https://www.example.com/wish3dearth/api/access/v1.0.0/getLicenseInfo API地址 POST /wish3dearth/api/material/shp/v1.0.
我使用< code>cairo_pdf()来生成一个字体很好的R绘图。如果我指定的字体系列具有合理命名的基本粗细,例如“Arial”包含Arial Regular、Arial Bold、Arial Italic、Arial Bold Italic,它会工作得很好。 但是有没有办法为给定样式任意设置字体?例如,在Hoefler Text中,我有Hoefler文本黑色而不是粗体。我可以cairo_pd
主要内容:颜色主题,实例,实例,实例,调色盘,实例,实例,直接的样式设置 itemStyle lineStyle areaStyle label ...,高亮的样式:emphasis,实例ECharts 可以通过样式设置来改变图形元素或者文字的颜色、明暗、大小等。 颜色主题 ECharts4 开始,除了默认主题外,内置了两套主题,分别为 light 和 dark。 使用方式如下: 实例 var chart = echarts.init(dom, 'light'); 或者 var chart =