gpt4 book ai didi

android - 我在使用 android :textSize ="?android:attr/textAppearanceLarge" in my xml 时遇到 LayoutInflater 错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:58:25 25 4
gpt4 key购买 nike

如果我在我的 xml 中使用 android:textSize="?android:attr/textAppearanceLarge",我的应用程序就会崩溃。我不想提供硬编码的文本大小,因为我必须为不同的屏幕大小创建 xml,或者我必须在运行时管理文本大小。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/title"
android:textSize="?android:attr/textAppearanceLarge" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/saveOnDialog"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/save"
style="?android:attr/buttonBarButtonStyle"
android:textSize="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/cancelOnDialog"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/cancel"
style="?android:attr/buttonBarButtonStyle"
android:textSize="?android:attr/textAppearanceLarge" />
</LinearLayout>
</LinearLayout>

这是 Log.e 输出 -

06-26 11:46:27.439: E/AndroidRuntime(1731):     at android.view.LayoutInflater.createView(LayoutInflater.java:620)
06-26 11:46:27.439: E/AndroidRuntime(1731): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
06-26 11:46:27.439: E/AndroidRuntime(1731): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:271)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.app.Dialog.setContentView(Dialog.java:479)
06-26 11:46:27.439: E/AndroidRuntime(1731): at com.umob.alerts.SaveDialog.showSaveDialog(SaveDialog.java:19)
06-26 11:46:27.439: E/AndroidRuntime(1731): at com.umob.notepad.NotepadScreen.onOptionsItemSelected(NotepadScreen.java:41)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.app.Activity.onMenuItemSelected(Activity.java:2566)
06-26 11:46:27.439: E/AndroidRuntime(1731): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:990)
06-26 11:46:27.439: E/AndroidRuntime(1731): at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
06-26 11:46:27.439: E/AndroidRuntime(1731): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
06-26 11:46:27.439: E/AndroidRuntime(1731): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
06-26 11:46:27.439: E/AndroidRuntime(1731): at com.android.internal.view.menu.MenuPopupHelper.onItemClick(MenuPopupHelper.java:156)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.widget.AdapterView.performItemClick(AdapterView.java:298)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.widget.AbsListView.performItemClick(AbsListView.java:1100)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2788)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.widget.AbsListView$1.run(AbsListView.java:3463)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.os.Handler.handleCallback(Handler.java:730)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.os.Handler.dispatchMessage(Handler.java:92)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.os.Looper.loop(Looper.java:137)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.app.ActivityThread.main(ActivityThread.java:5214)
06-26 11:46:27.439: E/AndroidRuntime(1731): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 11:46:27.439: E/AndroidRuntime(1731): at java.lang.reflect.Method.invoke(Method.java:525)
06-26 11:46:27.439: E/AndroidRuntime(1731): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
06-26 11:46:27.439: E/AndroidRuntime(1731): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
06-26 11:46:27.439: E/AndroidRuntime(1731): at dalvik.system.NativeStart.main(Native Method)
06-26 11:46:27.439: E/AndroidRuntime(1731): Caused by: java.lang.reflect.InvocationTargetException
06-26 11:46:27.439: E/AndroidRuntime(1731): at java.lang.reflect.Constructor.constructNative(Native Method)
06-26 11:46:27.439: E/AndroidRuntime(1731): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.view.LayoutInflater.createView(LayoutInflater.java:594)

最佳答案

使用 android:textAppearance="?android:attr/textAppearanceMedium"

代替

android:textSize="?android:attr/textAppearanceMedium"

关于android - 我在使用 android :textSize ="?android:attr/textAppearanceLarge" in my xml 时遇到 LayoutInflater 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24423868/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com