使用Android SDK,似乎没有任何方法可以在表格行上设置样式.我想做相同的:
<TableRow
style='@style/TableRow_classic' >
Run Code Online (Sandbox Code Playgroud)
在代码中.我想要像:
TableRow row = new TableRow(this);
row.setStyle(R.style.TableRow_classic);
Run Code Online (Sandbox Code Playgroud)
有谁知道如何找到这个?
我正在寻找一个看起来像的textview
.我用下面的代码来实现这个..
SpannableString text;
text = new SpannableString(bal_dollars.getText());
int index = bal_dollars.getText().toString().indexOf(".");
text.setSpan(new TextAppearanceSpan(getApplicationContext(),
R.style.HeroGraphicBalanceSmallFont), index, bal_dollars
.getText().toString().length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
bal_dollars.setText(text, TextView.BufferType.SPANNABLE);
Run Code Online (Sandbox Code Playgroud)
这是跨度中使用的样式..
<style name="HeroGraphicBalanceSmallFont" parent="@android:style/TextAppearance.Medium">
<item name="android:layout_width">wrap_content</item>
<item name="android:textSize">50sp</item>
<item name="android:singleLine">true</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_gravity">top|right</item>
<item name="android:paddingBottom">30dp</item>
<item name="android:gravity">top|right</item>
<item name="android:textColor">@color/status_text</item>
<item name="customFont">fonts/HeroicCondensedMedium.ttf</item>
</style>
Run Code Online (Sandbox Code Playgroud)
一切看起来都很好,除了目标文本跨度的间距,即小数部分重力.
.我尝试了所有的xml属性.请帮忙
我在Holo主题对话框中有一个微调器,我正在尝试更改文本颜色,因为它很难阅读:

我查看了android styles.xml以及许多其他答案,并且相信我正确地设置了自定义样式; 但它只是没有被捡起来.
这是微调器所在的对话框布局文件的摘录:
<Spinner
android:id="@+id/spn_Type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:entries="@array/dose_type_options"
style="@style/DialogSpinner" />
Run Code Online (Sandbox Code Playgroud)
这些是values-v14文件夹中styles.xml中的相关条目:
<style name="DialogSpinner" parent="@android:style/Widget.Holo.Spinner">
<item name="android:spinnerItemStyle">@style/MySpinnerItem</item>
</style>
<style name="MySpinnerItem" parent="android:Widget.Holo.TextView.SpinnerItem">
<item name="android:textAppearance">@style/MyTextAppearanceSpinnerItem</item>
</style>
<style name="MyTextAppearanceSpinnerItem" parent="android:TextAppearance.Holo.Widget.TextView.SpinnerItem">
<item name="android:textColor">#FFF</item>
</style>
Run Code Online (Sandbox Code Playgroud)
通过使用以下对话框本身被强制为Holo黑暗主题:
<style name="FibroDialog" parent="@android:style/Theme.Holo.Dialog">
</style>
Run Code Online (Sandbox Code Playgroud)
任何人都可以确定为什么微调文本不是白色的?
我看过其他解决方案,建议改变代码中的颜色,但这个应用程序支持2.3.*向上,所以对于那些非全息版本黑色文本很好,因此尝试按样式进行.
谢谢
使用Woda下面的答案更新
微调器的初始值的文本颜色现在是白色的,这对于突出显示用户有一个微调器非常重要:

但是可选项目的文本颜色仍然是黑色.我想这不是一个大问题,至少通过将初始文本变为白色来确认微调器的存在.但我很想知道为什么这些物品仍然是黑色的,以及如何将它们变成白色.
我正在尝试将我的应用程序中所有按钮的TextColor更改为白色,并尝试将其设置为粗体.但这没有发生,我正在覆盖the android:Widget.Button
我正在为Jelly Bean开发4.1.2我做错了什么?
清单中的主题定义
android:theme="@style/spui" >
Run Code Online (Sandbox Code Playgroud)
我喜欢的主题
<style name="spui" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:buttonStyle">@style/Buttonspui</item>
</style>
Run Code Online (Sandbox Code Playgroud)
按钮本身的样式
<style name="Buttonspui" parent="android:Widget.Button">
<item name="android:background">@drawable/btn_default_holo_light</item>
<item name="android:minHeight">48dip</item>
<item name="android:minWidth">64dip</item>
<item name="android:textColor">#ffffff</item>
<item name="android:textStyle">bold</item>
</style>
Run Code Online (Sandbox Code Playgroud)
按钮
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="@string/edit"
android:id="@+id/btnEdit"
style="@style/Buttonspui"/>
Run Code Online (Sandbox Code Playgroud) 我创建了一个自定义复合视图 - 视图加载,没有崩溃,到目前为止一切都很好.
现在,我计划在我的应用程序中使用此视图多次,因此视图需要一种样式.
我在attr.xml文件中声明了它的样式
<declare-styleable name="MyCustomView">
<attr name="ff_label" format="string" />
<attr name="ff_fieldText" format="string" />
</declare-styleable>
<declare-styleable name="MyCustomViewStyle">
<attr name="customViewStyle" format="reference" />
</declare-styleable>
Run Code Online (Sandbox Code Playgroud)
然后我去了我的主题文件并在里面写了这个
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
//bunch of other stuff
<item name="customViewStyle">@style/customViewStyle</item>
</style>
Run Code Online (Sandbox Code Playgroud)
然后在我的android清单中我宣布
<application
android:name="com.my.app.App"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
Run Code Online (Sandbox Code Playgroud)
然后在我写的styles.xml文件中
<style name="customViewStyleStyle" parent="@android:style/Widget.EditText">
<item name="android:paddingBottom">@dimen/space_between_adjacent_widgets_vertical</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="ff_label">@string/default_label_text</item>
<item name="ff_fieldText">@string/default_label_text</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我的问题:我的OWN属性被认可得很好.
为什么标记的属性被"android:..."忽略了? …
我想在我的应用程序中为Button提供以下设置.您可以将其视为按钮的一些主题更改.
样式圆形或正常
颜色红色或黄色或蓝色或任何颜色代码
我知道在XML中定义Shape,我可以实现Rounded Corners.有了setBackgroundColor,我可以将任何颜色设置为背景.
问题
根据我称之为的顺序setBackgroundColor,两者都 setBackground相互重叠.所以我无法在同一个按钮上实现这两种效果.我怎样才能同时实现这两种效果.如何从单个Button类中获得多个按钮.提前致谢.

绿色来自哪里?我已经尝试更改accentColor属性,该属性适用于应用程序的其他部分,但不在此处.
来自Lollipop的应用程序的屏幕截图.
我怎样才能改变颜色:
也许是未来的一些提示......你是怎么发现的?我一直在遇到所有这些令人困惑的颜色/造型问题.是否有某种列表告诉我,我需要为某个组件覆盖哪个默认颜色或属性?
使用SDK 22预览时,我的所有布局都出现以下渲染问题.
扩展类android.support.v7.widget.Toolbar时出错.
java.lang.NoSuchFieldError:View_theme
就我而言,问题是styles.xml:
带渲染问题的XML:
<resources>
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar" />
<!-- Base application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:textColorPrimary">@color/primary_text</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
XML没有问题:
<resources>
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar" />
<!-- Base application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:textColorPrimary">@color/primary_text</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
请注意我必须添加@style/父引用.这似乎解决了我的问题(重建后).
问题,这是我的错误还是错误?很多教程都没说(包括官方Android页面)
摇篮:
compileSdkVersion 22
buildToolsVersion '22.0.1'
minSdkVersion 15
targetSdkVersion 22
classpath 'com.android.tools.build:gradle:1.1.0'
Run Code Online (Sandbox Code Playgroud)
最后注意:我没有使用工具栏.
android android-appcompat android-support-library android-studio android-styles
我正在尝试设置材质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>
Run Code Online (Sandbox Code Playgroud)
然后我在我的主题上应用样式:
<style name="AppTheme">
<item name="editTextStyle">@style/AppTheme.EditText</item>
</style>
Run Code Online (Sandbox Code Playgroud)
并将主题应用于活动:
<activity
android:name=".MyActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="stateAlwaysHidden"
android:theme="@style/AppTheme">
Run Code Online (Sandbox Code Playgroud)
但是,这并没有改变下划线颜色.
我知道我可以更改accentColor以更改下划线颜色,但我不想这样做,因为我需要我的强调颜色与其他一些控件不同.
我可以设置控件下划线颜色吗?
android android-theme android-edittext android-styles material-design
我试图使用android黑暗主题。我安装了android studio 3.5预览版。
compileSdkVersion 28目标SdkVersion 28
但仍然出现此错误。这是黑暗主题错误还是我做错了什么?
build.gradle{
dependencies {
// ...
implementation 'com.google.android.material:material:1.1.0-alpha06'
// ...
}}
Run Code Online (Sandbox Code Playgroud)
styles.xml
<style name="Theme.MyApp" parent="Theme.MaterialComponents.DayNight">
<item name="android:forceDarkAllowed">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
项目链接