模拟 Android 偏好类别的外观/感觉

发布于 2024-09-11 21:41:02 字数 101 浏览 3 评论 0原文

我喜欢 Android 首选项类别中的标题栏样式。

在我的 Activity(不是 PreferenceActivity)中,如何使用相同的样式?

I like the title bar style from the Android preference category.

In my Activity (not a PreferenceActivity) How can I use the same style?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

贵在坚持 2024-09-18 21:41:02

由于我刚刚花了最后几个小时试图回答这个老问题,所以我会在这里为其他人做这件事。
事实证明,首选项类别样式使用的资源是 listSeparatorTextViewStyle。

您可以这样使用它:

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello, World"
style="?android:attr/listSeparatorTextViewStyle"/>

使用 style="?android:attr/preferenceCategoryStyle" 不起作用。

Since I just spent the last few hours trying to answer this old question, I'll do it here for anyone else.
It turns out the resource the preference category style is using is listSeparatorTextViewStyle.

You use it like this:

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello, World"
style="?android:attr/listSeparatorTextViewStyle"/>

Using style="?android:attr/preferenceCategoryStyle" didn't work.

吃兔兔 2024-09-18 21:41:02

主要布局很可能是带有 LinearLayout 的 ScrollView。至于单独的布局,我相信(只是在查看文档后猜测)您可以使用 android.R.attr 中的各种属性 - 请看这里: http://developer.android.com/reference/android/R.attr.html。有一些属性,例如preferenceCategoryStyle、preferenceStyle 等。您可以将任何样式应用到任何视图。

The main layout is most likely a ScrollView with a LinearLayout. As for the individual layout, I believe (just guessing after looking at the documentation) that you can use the various attributes in android.R.attr - look here: http://developer.android.com/reference/android/R.attr.html. There are attributes like preferenceCategoryStyle, preferenceStyle, etc. You can apply any style to any of your views.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文