Get Electrical Flow Setting Of Font Scale

Posted on

Android illustration to become electrical flow user preference for the scaling element for fonts, relative to the base of operations density scaling, past times reading getResources().getConfiguration().fontScale.

MainActivity.java

package com.blogspot.android_er.androidfontscale;  import android.provider.Settings; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; import android.widget.Toast;  populace bird MainActivity extends AppCompatActivity {      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);          TextView prompt = (TextView)findViewById(R.id.prompt);          float fontScale = getResources().getConfiguration().fontScale;         prompt.setText("fontScale:: " + fontScale);      } }  

layout/activity_main.xml

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:padding="16dp"     android:orientation="vertical"     tools:context="com.blogspot.android_er.androidfontscale.MainActivity">      <TextView         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_horizontal"         android:autoLink="web"         android:text="https://rootandroid.org//"         android:textStyle="bold" />      <TextView         android:id="@+id/prompt"         android:layout_width="match_parent"         android:layout_height="wrap_content" /> </LinearLayout>