Arthur
Arthur

Reputation: 159

How to set same text size in android app?

I'm wondering how to make your MainScreen text same size on all devices(I'm using android studio) I have 65dp text, but once I run it on emulator which has bigger screen my text is much smaller.

Upvotes: 3

Views: 194

Answers (2)

Gabriella Angelova
Gabriella Angelova

Reputation: 2985

You could use the current resolution of the screen and the text size will be proportional for every single device. In this way you could use something like this:

//get your textView
TextView text = (TextView) findViewById(R.id.titleField);
text.setText("Your title here");
text.setTextSize(65 * getResources().getDisplayMetrics().density);

you could do this for every TextView in your MainScreen. Hopefully this helps you :)

P.S. You could find more suggestions for your case here: Text size with different resolution

Upvotes: 0

Durga Mohan
Durga Mohan

Reputation: 1110

Never use "dp" for specifying textsizes. Always use "sp" for textsize and "dp" for everything else.

android:textSize="25sp"

android:layout_width="50dp"

Upvotes: 1

Related Questions