开发者

How to use size of font from edittext hint in another view

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 t开发者_高级运维ried 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜