我试图从材料组件主题更改样式属性(像colorPrimaryVariant,colorOnSecondary等等),但我收到以下错误:
Android resource linking failed
Output: C:\...\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3835: error: style attribute 'attr/colorPrimaryVariant (aka com.sample.app:attr/colorPrimaryVariant)' not found.
C:\...\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3836: error: style attribute 'attr/colorOnPrimary (aka com.sample.app:attr/colorOnPrimary)' not found.
C:\...\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3839: error: style attribute 'attr/colorSecondaryVariant (aka com.sample.app:attr/colorSecondaryVariant)' not found.
C:\...\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3840: error: style attribute 'attr/colorOnSecondary (aka com.sample.app:attr/colorOnSecondary)' not found.
error: failed linking references.
Run Code Online (Sandbox Code Playgroud)
这就是我的主题:
<resources>
<!-- Light application theme -->
<style name="CBTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="colorPrimary">@color/cbPrimary</item>
<item name="colorPrimaryDark">@color/cbPrimaryDark</item>
<item name="colorPrimaryVariant">@color/cbPrimaryDark</item>
<item name="colorOnPrimary">#FFFFFF</item>
<item name="colorAccent">@color/cbAccent</item>
<item name="colorSecondary">@color/cbAccent</item>
<item name="colorSecondaryVariant">@color/cbAccentLight</item>
<item name="colorOnSecondary">#FFFFFF</item>
<item name="colorError">@color/cbRed</item> …Run Code Online (Sandbox Code Playgroud) android android-theme material-components material-components-android
昨天我在Android上寻找滑块,发现这个网站有谷歌搜索:https://material.io/guidelines/components/sliders.html#sliders-discrete-slider
我知道我可以SeekBar在Android中使用一个来实现滑块.但是,Google似乎有非常好的离散滑块示例,但我找不到任何代码示例.
我已经实现了一个SeekBar看起来像这样的法线:
我怎么能让它看起来像这样?
(差异:当我移动滑块时,没有显示当前值的大幅下降)
我想我可能只是错过了这些设计指南的代码文档.有谁知道在哪里找到它?或者是设计上的差异,因为我在手机上安装了Android 5.0.2?
android android-seekbar material-components material-components-android android-slider
我需要帮助.如何在样式应用程序中更改snackbar中文本的设计?代码的变化对我不感兴趣.我找到了以下代码.但这对我不起作用.这是为什么?我的主题来自@ style/Theme.AppCompat.Light.DarkActionBar".我非常感谢你的帮助.
<style name="TextAppearance.Design.Snackbar.Message" parent="android:TextAppearance">
<item name="android:textSize">10sp</item>
<item name="android:textColor">#FEFEFE</item>
</style>
<style name="TextAppearance.Design.Snackbar.Action" parent="android:TextAppearance">
<item name="android:textSize">16sp</item>
<item name="android:textColor">#FEFEFE</item>
</style>
Run Code Online (Sandbox Code Playgroud) android styles android-snackbar material-components material-components-android
虽然有一个类似的问题,但它并没有给我一个解决方案。当我尝试使用com.google.android.material.floatingactionbutton.FloatingActionButton它时运行良好。但是如果我尝试使用com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton,它会出错。
我在 XML 文件中的代码:
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/book_profile_write_review"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:contentDescription="@string/author_name"
android:text="@string/book_name"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@drawable/ic_launcher_foreground" />
Run Code Online (Sandbox Code Playgroud)
日志猫:
2019-11-14 12:30:21.997 21326-21326/com.bookaholic.shahad.bookaholicbd E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.bookaholic.shahad.bookaholicbd, PID: 21326
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bookaholic.shahad.bookaholicbd/com.bookaholic.shahad.bookaholicbd.activities.BookProfile}: android.view.InflateException: Binary XML file line #25: Binary XML file line #25: Error inflating class com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2974)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3059)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1724)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7000)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
Caused by: android.view.InflateException: Binary …Run Code Online (Sandbox Code Playgroud) android floating-action-button material-components material-components-android
新款上没有涟漪MaterialCardView吗?
我曾经使用CardView过android:clickable="true",android:foreground="?android:attr/selectableItemBackground"并且工作得很好但是新的MaterialCardView并没有任何涟漪.
其他Views等继续工作,但我希望我的卡可以点击(以涟漪作为反馈).
所有材料-ui示例都显示了Appbar中的工具栏.为什么不只是Appbar?这两者有什么区别?
https://material.io/design/components/并没有有工具栏组成部分,只有"应用吧:顶".
https://material.io/develop/web/components/toolbar/说"将来的版本中将删除现有的MDCToolbar组件和样式"
材料 - 工具栏最终会消失吗?
我怎样才能强迫一个ChipGroup人像RadioGroup至少一个选定的项目一样?设置setSingleSelection(true)还增加了在a上单击两次时没有选择任何内容的可能性Chip.
android android-chips material-components material-components-android
我正在使用supportLibrary =“ 28.0.0-beta01”版本。
这是我在.xml文件中的代码:
<android.support.design.button.MaterialButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_my_orders"
app:iconGravity="textStart"
android:gravity="center"/>
Run Code Online (Sandbox Code Playgroud)
到我的代码图标的可绘制位置位于按钮的左侧。我想将按钮设置在中间。
我想达到这个结果

我不需要任何自定义视图或硬编码的东西。如果这是一个错误(app:iconGravity),我将等待下一个版本。
在版本28.0.0-rc01中修复的错误,只需更改版本即可。
我在我的应用程序中使用 MaterialComponents.DayNight 主题。在白天模式下,工具栏文本颜色为黑色。但是当我切换到夜间模式工具栏文本颜色保持黑色,所以它不再可见。
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
Run Code Online (Sandbox Code Playgroud)
我想在夜间模式下将工具栏文本颜色更改为白色。我怎样才能做到这一点?
android android-styles android-toolbar material-components material-components-android