Text size within an PreferenceScreen

后端 未结 2 701
半阙折子戏
半阙折子戏 2021-02-10 08:52

I have xml file that defines some preference screens like the following example



        
2条回答
  •  [愿得一人]
    2021-02-10 09:18

    You can simply add android:textSize inside your theme for preference screen:

    e.g :

    
    

    Your SettingsActivity class :

    public class SettingsActivity extends AppCompatActivity {
    private Toolbar toolbar;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings);
    
        toolbar = (Toolbar)findViewById(R.id.toolbar_settings);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.bodylayout, new PrefsFragment())
                .commit();
    
    
    }
    
    @Override
    protected void onPause() {
        super.onPause();
    }
    }
    

    PrefsFragment class :

    public class PrefsFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
    
        @Override
        public void onCreatePreferences(Bundle bundle, String s) {
    
        }
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            final Context myContext = this.getActivity();
        //set your theme
            myContext.setTheme(R.theme.settingsTheme);
    
            super.onCreate(savedInstanceState);
            addPreferencesFromResource(R.xml.settingspreference);
        //do other stuffs
            }
        //.....
            }
    

提交回复
热议问题