【问题标题】:How to inhrit style="?android:listSeparatorTextViewStyle" style and change the line color to blue?如何继承 style="?android:listSeparatorTextViewStyle" 样式并将线条颜色更改为蓝色?
【发布时间】:2013-10-26 08:35:22
【问题描述】:

我想在我在这篇文章中遇到this post 的蓝色文本视图下方有一条线,这是我尝试过的答案之一,并且工作正常,但我想更改textview 和它下面的行。

只需添加此样式:

style="?android:listSeparatorTextViewStyle"

到你的 TextView

我也尝试过提取样式,但在继承上述样式时出现错误

我的风格如下

<style name="blueBoldText" parent="?android:listSeparatorTextViewStyle">
    <item name="android:textColor">@color/DarkTurquoise</item>
    <item name="android:textStyle">bold</item>
</style>

【问题讨论】:

  • 您找到解决方案了吗?

标签: android styles textview


【解决方案1】:

其实就是属性的值

?android:listSeparatorTextViewStyle

@android:style/Widget.Holo.Light.TextView.ListSeparator

所以你可以继承这种风格。

【讨论】:

  • 请解释一下您是如何发现这两者之间的关系的?我在哪里可以检查它?谢谢!更新:现在我看到了,在这里:github.com/android/platform_frameworks_base/blob/master/core/…
  • 我只使用“搜索声明”功能(F3 sur Eclipse 和 Ctrl-B sur Android Studio)。我将打开声明。或者如果你在平台的源文件夹中搜索文本,你会发现这行代码:@android:style/Widget.Holo.Light.TextView.ListSeparator跨度>
  • 这不再公开了吗?尽管编辑器似乎接受了该值,但编译器会生成:Error retrieving parent for item: No resource found that matches the given name '@android:style/Widget.Holo.Light.TextView.ListSeparator'.
【解决方案2】:

你可以扩展TextView并设置listSeparatorTextViewStyle。

public class HeaderView extends TextView {
    public HeaderView(Context context) {
        super(context, null, android.R.attr.listSeparatorTextViewStyle);
    }
    public HeaderView(Context context,
                    AttributeSet attrs) {
        super(context, attrs, android.R.attr.listSeparatorTextViewStyle);
    }
}

然后

<com.gmail.sikambr.alib.HeaderView
    style="@style/your_style"
    android:text="..."
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多