user1835954
user1835954

Reputation: 51

How to Set same text in Different Resolution in Android?

i want to Set same size text in Different Resolution.How to do this.I also tried by creating two new folder like layout-small,layout-large,layout-xlarge,layout-normal.but still not manage it.Please someone help me for my issue.Thank You.

Upvotes: 0

Views: 202

Answers (3)

Lord Nick
Lord Nick

Reputation: 583

In your xml use something like this to set the Size of the text . It will be independent of the resolution.

 <TextView android:id="@+id/name_text"
        android:layout_height="wrap_content"
        android:layout_width="match_parent" 
        android:textSize="10dp"
        />

or you can do this in the java code by

    TextView text1 = (TextView) findViewById(R.id.txt);
    text1.setTextSize(10);

Upvotes: 5

Abx
Abx

Reputation: 2882

if you use textSize="xdip" it will adjust according to the resolution and if you use textsize="xpx" the text size will be same ...

Upvotes: 1

Jorge
Jorge

Reputation: 487

Use textSize="XXdp" (that is, specify dp units instead of px) to achieve density independence. This will show the text with the same size in every device. The layout-small, layout-large, etc. folders are used to provide different layouts (e.g. a layout for a mobile phone and a different layout for tablets), not text sizes.

Upvotes: 0

Related Questions