如何在另一个视图中使用编辑文本提示中的字体大小

发布于 2024-11-02 05:03:33 字数 262 浏览 0 评论 0原文

我想在另一个视图(特别是 TextView)中使用 EditText 提示的字体类型、颜色和大小,以在表单的其他区域中保持一致的外观。我怎样才能知道要使用什么?

我尝试在 sdk 中寻找 EditText 布局,但找不到,我希望用它来找到我可以设置的相应属性。可能类似于

android:textAppearance="?android:attr/textAppearanceSmallInverse"

有人做过类似的事情吗?

I want to use the font type, color and size of the EditText hint in another view (sepcifically a TextView) to keep a consistent look in other areas of my form. How to I find out what to use?

I have tried looking for an EditText layout in the sdk but I couldn't find one, I was hoping to use that to find the corresponding attribute that I can set. Probably something along the lines of

android:textAppearance="?android:attr/textAppearanceSmallInverse"

Anyone done anything similar?

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

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

发布评论

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

评论(1

情魔剑神 2024-11-09 05:03:33

我找到了一个有效的解决方案(至少在模拟器和我的 HTC Hero 上)

我检查了 android/widget/TextView.java 中的代码并进行了修改,直到我想出了这个...

<TextView 
android:text="This one has the hint style text"
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorHint"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
/>

<TextView 
android:text="This one has the value style text"
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
/>

我想这可能不是正确的解决方案,因为 textAppearanceMediumInverse 在大型或小型设备上看起来不正确,但现在可以使用...


编辑设备大小无关

这似乎解决了小/中/大问题

<TextView 
android:text="This one has the hint style text"
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorHint"
android:textAppearance="?android:attr/textAppearance"
/>

<TextView 
android:text="This one has the value style text"
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceInverse"
/>

我将暂时保留这个问题,如果有人有我可以接受更好的答案,但这看起来对我有用。

I've found a solution that works (at least in the emulator and on my HTC Hero)

I examined the code in android/widget/TextView.java and tinkered about until I came up with this...

<TextView 
android:text="This one has the hint style text"
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorHint"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
/>

<TextView 
android:text="This one has the value style text"
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
/>

I guess this is probably not the right solution, because textAppearanceMediumInverse won't look right on a Large or Small device but this works for now...


Edit device size independent

This seems to solve the small/medium/large problem

<TextView 
android:text="This one has the hint style text"
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorHint"
android:textAppearance="?android:attr/textAppearance"
/>

<TextView 
android:text="This one has the value style text"
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceInverse"
/>

I'll leave this question open for a while, in case someone has a better answer that I can accept but this looks like it is working for me.

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