<TextView
android:id="@+id/headertext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="48dip"
android:textSize="24dip"
android:text="My Dresses"
/>
But what if, within the Activity code, I want to change one of these measurements? There are no Java methods in the Android SDK that accept density independent pixels!
Well, here's how. Just multiply the size in pixels by a scale factor defined in the context's resources, like so:
float scale = context.getResources().getDisplayMetrics().density;
float size = sizeInPixels * scale;
And there's that. I hope it helps :) Please join the conversation with a comment.
This comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDelete