Reputation: 1
How should I resize text, button images, etc. to different screens? For example, to make text or images look readable on both large and small screens. It is written on the Internet that you need to create folders with the prefixes hdpi, mdpi, and so on, but this is not an adaptation, but a simple creation of several xml markup and thereby takes up extra memory space. I would like to use something like percentage or are there other solutions?
Upvotes: 0
Views: 583
Reputation: 493
I recommend this library to you https://github.com/intuit/sdp
An android lib that provides a new size unit - sdp (scalable dp). This size unit scales with the screen size. It can help Android developers with supporting multiple screens.
All you need is to add its dependencies for none Text sizes use this
dependencies {
implementation 'com.intuit.sdp:sdp-android:1.0.6'
}
And this an example of it on XML
<LinearLayout
android:id="@+id/give_us_a_review_landmine_main_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="@dimen/_27sdp"
android:paddingLeft="@dimen/_43sdp"
android:paddingRight="@dimen/_43sdp"
android:paddingTop="@dimen/_50sdp" >
for fonts size use this
dependencies {
implementation 'com.intuit.ssp:ssp-android:1.0.6'
}
this example for using the text size
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Intuit"
android:textColor="@android:color/black"
android:textSize="@dimen/_40ssp"/>
Upvotes: 1