My application is crashing if I am using android:textSize="?android:attr/textAppearanceLarge"
in my xml . I don't want to give hard coded text size because the I have to create create xml for different screen sizes or I have to manage the text size at run time.
<?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>
Here is the Log.e output -
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)
Use android:textAppearance="?android:attr/textAppearanceMedium"
instead of
android:textSize="?android:attr/textAppearanceMedium"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With