Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I scale a View in Android?

Can I take a view that has been rendered by the Android framework and rescale it to some other size?

like image 331
bjdodson Avatar asked Oct 01 '11 11:10

bjdodson


People also ask

What is scaling in Android Studio?

android.icu.number.Scale. A class that defines a quantity by which a number should be multiplied when formatting. To create a Multiplier, use one of the factory methods. See also: NumberFormatter.


2 Answers

You need API 11 or above to scale a view. Here is how:

float scalingFactor = 0.5f; // scale down to half the size view.setScaleX(scalingFactor); view.setScaleY(scalingFactor); 
like image 57
Gadzair Avatar answered Oct 17 '22 17:10

Gadzair


In your XML

android:scaleX="0.5" android:scaleY="0.5" 
like image 26
Taiti Avatar answered Oct 17 '22 17:10

Taiti