android - 如何使 PreferenceScreen 的标题可调整大小?
问题描述
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/game_title">
我为我的应用添加了标题的首选项屏幕。当应用程序在分屏中打开并在窗口中调整为不同大小时,当存在的宽度较小时,标题会消失。
尝试添加,
android:layout_height="wrap_content"
android:layout_width="wrap_content"
财产,PreferenceScreen
但它没有帮助。一些帮助将不胜感激。
解决方案
就像在这个答案中一样,您可以为该创建自定义布局PreferenceScreen
并将其与android:layout
属性一起应用
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:layout="@layout/preference_title"
android:title="@string/game_title">
preference_title.xml 布局
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/preference_title"/>
并创建不同版本的文件以具有与可能的屏幕宽度成比例res/values/dimen.xml
的标题文本大小(@dimen/preference_title
values
values-w600dp
推荐阅读
- php - PHP-如何在用户访问网站之前添加“输入密码”屏幕
- reactjs - 在 react.js 中发送消息返回 id 而不是消息
- c++ - 为什么在以下代码中调用 D3DXQuaternionToAxisAngle?
- c++ - 无法在循环c ++中打印输出
- javascript - 有没有办法从布局“单词”中的字典中获取所有单词,
- javascript - 在javascript中查找数组子数组之间的交集
- c++ - 如何获得 Win32 C/C++ 程序的命令行选项?
- oracle - PL/SQL 程序将代码分成两部分
- php - 在 WordPress 中呈现自定义帖子类型的正确方法是什么?
- kubernetes - 这些 Kubernetes 注释的含义是什么?