neo*_*nic 8 android android-collapsingtoolbarlayout
我有折叠工具栏的问题,在展开状态下我想在文本下面有模糊的阴影,我使用这段代码:
collapsingToolbar.setExpandedTitleTextAppearance(R.style.toolbar_text);
Run Code Online (Sandbox Code Playgroud)
用:
<style name="toolbar_text">
<item name="android:textColor">@color/white</item>
<item name="android:shadowColor">@color/black</item>
<item name="android:shadowDx">2</item>
<item name="android:shadowDy">2</item>
<item name="android:shadowRadius">4</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我可以改变它textColor,它有效,但阴影不起作用.我为阴影尝试了许多不同的值.
是否可以为折叠文本投射阴影?因为在浅色图像上,标题有时难以阅读.
看起来,从设计支持 lib 版本开始22.2.1,这是不可能的。
这是设置文本外观的反编译方法:
void setExpandedTextAppearance(int resId) {
TypedArray a = this.mView.getContext().obtainStyledAttributes(resId, styleable.TextAppearance);
if(a.hasValue(styleable.TextAppearance_android_textColor)) {
this.mExpandedTextColor = a.getColor(styleable.TextAppearance_android_textColor, 0);
}
if(a.hasValue(styleable.TextAppearance_android_textSize)) {
this.mExpandedTextSize = (float)a.getDimensionPixelSize(styleable.TextAppearance_android_textSize, 0);
}
a.recycle();
this.recalculate();
}
Run Code Online (Sandbox Code Playgroud)
它仅设置文本颜色和大小。
更新:既然您提到需要为标题添加阴影以使其在浅色背景上更容易阅读,我建议您将扩展标题颜色更改为深色。例如
collapsingToolbar.setExpandedTitleColor(0x000);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3449 次 |
| 最近记录: |