text-size

How to assign text size in sp value using java code

一曲冷凌霜 提交于 2019-11-27 16:44:32
If I assign an integer value to change a certain text size of a TextView using java code, the value is interpreted as pixel ( px ). Now does anyone know how to assign it in sp ? Santosh http://developer.android.com/reference/android/widget/TextView.html#setTextSize%28int,%20float%29 Example: textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 65); You can use a DisplayMetrics object to help convert between pixels and scaled pixels with the scaledDensity attribute . DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); pixelSize = (int)scaledPixelSize *

Android: measureText() Return Pixels Based on Scaled Pixels

坚强是说给别人听的谎言 提交于 2019-11-27 13:14:58
So I use Paint's measureText() method to measure the width of a segment of text, but I wanted to measure text based on a certain text size. Say I wanted to get the width of a text segment that will be 20 scaled pixels when it occupies a certain TextView. I tried the following: Paint paint = new Paint(); paint.setTextSize(20); paint.measureText("sample text"); However, it does not seem to be working. I believe it is returning a width with respect to a smaller text size. I feel like I'm missing something that will make me slap myself in the face and yell herp derp. You need to get the

Dynamic Text size change according to tablet

♀尐吖头ヾ 提交于 2019-11-27 12:31:11
问题 With all effort,I finally reached to the end of my first app in android. And thanks to all. But after coming to end, I realized one thing that my app text size is common in all tablet sizes. So I will re frame my question. Problem: I used my own custom text size in entire app. and some what satisfied with 7 inch tablet. But when I am looking the same thing in 8.9 inches and 10.1 inch tablet its containing lots of white spaces and text size are also relatively small. So is there some way that

Text size of android design TabLayout tabs

你。 提交于 2019-11-27 06:39:21
I have difficulties changing the text size of the tabs of design library tablayout (android.support.design.widget.TabLayout). I managed to change it by assigning tabTextAppearance in TabLayout app:tabTextAppearance="@style/MyTabLayoutTextAppearance" the following style <style name="MyTabLayoutTextAppearance" parent="TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse"> <item name="android:textSize">14sp</item> </style> but I have 2 side effects : 1) I lost the accent color of the selected tab 2) The tab text is not capitalized any more. hnrain <style name="MineCustomTabText" parent=

How to change the toolbar text size?

不问归期 提交于 2019-11-27 06:21:47
I want to change the size of text in Toolbar . Because in my application, Toolbar text has different sizes both for landscape and portrait mode. Is it possible to change the text size of text in Toolbar ? Use app:titleTextAppearance : <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="?actionBarSize" android:id="@+id/toolbar" app:titleTextAppearance="@style/Toolbar.TitleText" /> and override the default title size in a custom style: <style

What is the default text size on Android?

試著忘記壹切 提交于 2019-11-27 04:10:39
问题 I have a mixture of Buttons and an own View, where I set my text size using Paint.setTextSize(). I want the text size to look the same like the text on the Button. Now, I can of course set the text size of the button to e.g. 18sp, and use 18 in my view. But for a better integration, I simply would like to know, what text size is "normal" for buttons. From my test, it should be something like 12sp, but I have not found any documentation on this. Leaving the default sizes leaves way too small

How to change size of title's text on Action Bar?

╄→гoц情女王★ 提交于 2019-11-26 22:47:39
There is an ActionBar on each Android 4.0 application, and it got a title. I need to make this size less. But I don't understand how I can do it, because ActionBar doesn't provide public methods for it. Remark: I don't want to use custom views. Actually, you can do what you want to customize the ActionBar. It must be done through the Theme. You can do something like this : <style name="Theme.YourTheme" parent="android:style/Theme"> <item name="android:actionBarStyle">@style/Theme.YourTheme.Styled.ActionBar</item> </style> <style name="Theme.YourTheme.Styled.ActionBar"> <item name="android

Get the size of a text in TextView

£可爱£侵袭症+ 提交于 2019-11-26 22:46:05
问题 I have a problem placing a textView at specified center's x and y coordinates. Firstly, I tried to set the text in the textView, and to move the view with the width and the height of the view from this link. But it doesn't work, and I'd like to try something else. I'd like to know if there is a method to get the size which a specified text will take in my textView? I mean, I know the text and the textSize, how can I get the width and the height my textView will take? Something like the method

How to auto-adjust text size on a multi-line TextView according to the view max dimensions?

落爺英雄遲暮 提交于 2019-11-26 18:07:03
问题 I've been searching for a way of auto fit a text inside a textview. Through my search I've found many solutions like: FontFitTextView AutoResizeTextView AutoScale/Resize But like many others these doesn't solve my problem. They don't work as expected when we use a TextView with multiline. Basically my goal is this one: As you can see, the text resizes based on width, height and also pays attention to the line break, creating a multi-line textview. Also be able to change the typeface. One of

How to change size of title&#39;s text on Action Bar?

与世无争的帅哥 提交于 2019-11-26 12:19:44
问题 There is an ActionBar on each Android 4.0 application, and it got a title. I need to make this size less. But I don\'t understand how I can do it, because ActionBar doesn\'t provide public methods for it. Remark: I don\'t want to use custom views. 回答1: Actually, you can do what you want to customize the ActionBar. It must be done through the Theme. You can do something like this : <style name="Theme.YourTheme" parent="android:style/Theme"> <item name="android:actionBarStyle">@style/Theme