I haven't changed anything relating to my settings between this build and the last one which works.
The crash occurs on API 16 whereas on API 23 it works fine. This is in Genymotion. I do not have a lower real device accessible.
EDIT - I have since tested it on a Sony Xperia U running 4.0.4 and the same crash occurs.
I believe I have tracked it down to being due to upgrading the support libraries to 23.2.0 as I have since downgraded and it works again.
Anyone else experiencing this?
03-01 18:36:20.693 1846-1846/? E/AndroidRuntime: FATAL EXCEPTION: main
android.view.InflateException: Binary XML file line #19: Error inflating class android.widget.CheckBox
at android.view.LayoutInflater.createView(LayoutInflater.java:613)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at android.preference.Preference.onCreateView(Preference.java:480)
at android.preference.Preference.getView(Preference.java:451)
at android.preference.PreferenceGroupAdapter.getView(PreferenceGroupAdapter.java:221)
at android.widget.AbsListView.obtainView(AbsListView.java:2267)
at android.widget.ListView.makeAndAddView(ListView.java:1769)
at android.widget.ListView.fillDown(ListView.java:672)
at android.widget.ListView.fillFromTop(ListView.java:733)
at android.widget.ListView.layoutChildren(ListView.java:1608)
at android.widget.AbsListView.onLayout(AbsListView.java:2102)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1866)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1687)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:587)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at android.preference.Preference.onCreateView(Preference.java:480)
at android.preference.Preference.getView(Preference.java:451)
at android.preference.PreferenceGroupAdapter.getView(PreferenceGroupAdapter.java:221)
at android.widget.AbsListView.obtainView(AbsListView.java:2267)
at android.widget.ListView.makeAndAddView(ListView.java:1769)
at android.widget.ListView.fillDown(ListView.java:672)
at android.widget.ListView.fillFromTop(ListView.java:733)
at android.widget.ListView.layoutChildren(ListView.java:1608)
at android.widget.AbsListView.onLayout(AbsListView.java:2102)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4362)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1866)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1687)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_btn_check_material.xml from drawable resource ID #0x7f020003
at android.content.res.Resources.loadDrawable(Resources.java:1918)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.widget.CompoundButton.<init>(CompoundButton.java:74)
at android.widget.CheckBox.<init>(CheckBox.java:68)
at android.widget.CheckBox.<init>(C
Need to make changes in your gradle.
See My answer for same issue: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016
Hope its helps you.
What is helped me is extending AppCompatActivity insted of Activity in my preferences screen
As you are using the support library, I assume that there is no issue if you use the AppCompatCheckbox instead of the standard once.
You can do this with a custom layout that is pretty much identical to the standard one but replaces the Checkbox with the AppCompatversion.
As we are no longer using the standard Checkbox layout where the error occurs, the crash no longer happens.
I prefer this method even when the support library is working correctly as it allows me to replace the AppCompatCheckbox with an AppCompatRadioButton when the need arises.
PreferenceScreen xml:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference android:layout="#layout/custom_checkbox_pref" android:key="whatever" android:title="The Title"/>
</PreferenceScreen>
Layout: custom_checkbox_pref.xml
<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="wrap_content"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingEnd="?android:attr/scrollbarSize"
tools:ignore="RtlSymmetry">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"
android:layout_marginEnd="6dp"
android:layout_marginStart="15dp"
android:layout_marginTop="6dp"
android:layout_weight="1">
<TextView
android:id="#android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:text="Title"/>
<TextView
android:id="#android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#android:id/title"
android:layout_below="#android:id/title"
android:maxLines="4"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Summary"/>
</RelativeLayout>
<android.support.v7.widget.AppCompatCheckBox
android:id="#+android:id/checkbox"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:clickable="false"
android:focusable="false"/>
</LinearLayout>
Related
In the Material Design TextLayoutinput endIconMode attribute not found how to archive below design
Thanks Advance !
you could add a right drawable to TextInputEditText like :
<android.support.design.widget.TextInputLayout
android:id="#+id/til_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:boxBackgroundMode="outline"
android:layout_margin="10dp">
<android.support.design.widget.TextInputEditText
android:id="#+id/tiet_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="#drawable/icon"//add the right drawable
android:inputType="textPassword"/>
</android.support.design.widget.TextInputLayout>
Work for me
<com.google.android.material.textfield.TextInputLayout
...
app:endIconDrawable="#drawable/ic_close_gray_24dp"
app:endIconMode="custom">
I have a gridview in my app and i'm able to increase its height dynamically. But my issue is that every time i increase the height, the scrollbar scrolls to the center of the page. What could cause this issue ? Here is my code below :
Axml :
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:background="#e1effa">
<GridView
android:id="#+id/gvPhones"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:verticalSpacing="5dp"
android:drawSelectorOnTop="true"
android:stretchMode="columnWidth" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Cs :
_mySimpleItemLoader = new LoadRecords();
_mySimpleItemLoader.LoadMoreItems();
gvPhone = FindViewById<GridView>(Resource.Id.gvPhones);
_gridviewAdapter = new PhonesAdapter(this, _mySimpleItemLoader, this);
gvPhone.Adapter = _gridviewAdapter;
gvPhone.LayoutParameters.Height = 777 * gvPhone.Count;
But my issue is that every time i increase the height, the scrollbar scrolls to the center of the page.
When you open an Activity, some control needs to take focus. But in your .axml layout there's no designated control to take focus, the system chooses the first eligible control that wants focus.
When you set the android:focusableInTouchMode="true" property in your LinearLayout, your LinearLayout will be focused on start and your NestedScrollView won't scroll to the center of the page.
I'm trying to use WearableActionDrawer in my app. Previously I was using 'com.google.android.support:wearable:2.0.0-alpha1' and my layout looks like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.drawer.WearableDrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:rectLayout="#layout/rect_activity_main"
app:roundLayout="#layout/round_activity_main"
tools:context="com.example.grant.wearableclimbtracker.MainActivity"
tools:deviceIds="wear">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id = "#+id/content_frame">
<android.support.wearable.view.GridViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.NestedScrollView>
<android.support.wearable.view.drawer.WearableNavigationDrawer
android:id = "#+id/top_navigation_drawer"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#color/dark_grey"/>
<android.support.wearable.view.drawer.WearableActionDrawer
android:id="#+id/bottom_action_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey" />
</android.support.wearable.view.drawer.WearableDrawerLayout>
After I switched to 'com.google.android.support:wearable:2.0.0' the behavior changed. The action drawer used to stay out of view until I swiped up to reveal the action menu, but now there is a peek view of the drawer that doesn't go away unless I open the menu and select something. Is this the intended behavior? It takes up a lot of real-estate:
Any advice would be much appreciated.
It was as I suspected, when NestedScrollingChild height matched the parentview, the action drawer peeks. The only way I could get it to hide was to increase the NestedScrollingChild view by 1dp:
// get the screen width
DisplayMetrics metrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
// set height of framelayout to be slightly larger than view
mSessionLayout = rootView.findViewById(R.id.sessionLayout);
mSessionLayout.setMinimumHeight(metrics.heightPixels+1);
I'm trying to make an Android Wear app that has two pages.
I created:
InsetActivity
GridViewPager
FragmentGridPagerAdapter
Two classes extended from CardFragment
Two custom layout files that use BoxInsetLayout
One of the layout files is as follows:
<android.support.wearable.view.BoxInsetLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/history_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background">
<FrameLayout
android:id="#+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_box="all">
<android.support.wearable.view.WearableListView
android:id="#+id/history_list"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.wearable.view.WearableListView>
</FrameLayout>
</android.support.wearable.view.BoxInsetLayout>
InsetActivity.isRound() returns true, but BoxInsetLayout.isRound() returns false.
Two error messages are shown in console:
E/RecyclerView﹕ No adapter attached; skipping layout
What's wrong?
I'm trying to use .addView to add another LinearLayout to the ViewGroup.
I am getting the following error on LogCat:
05-21 16:23:04.096: E/AndroidRuntime(2086): FATAL EXCEPTION: main
05-21 16:23:04.096: E/AndroidRuntime(2086): java.lang.NullPointerException
05-21 16:23:04.096: E/AndroidRuntime(2086): at android.view.ViewGroup.addView(ViewGroup.java:3148)
05-21 16:23:04.096: E/AndroidRuntime(2086): at android.view.ViewGroup.addView(ViewGroup.java:3131)
This is the code being called:
final LinearLayout eventContainerSub =
(LinearLayout) findViewById(R.layout.event_container);
final LinearLayout eventContainer =
(LinearLayout) findViewById(R.id.eventContainer);
eventContainer.addView(eventContainerSub);
Here is the ViewGroup (the first linear layout):
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:id="#+id/eventContainer"
android:weightSum="100"
android:duplicateParentState="true">
And this is the (second) LinearLayout I'm adding to the (first one) LinearLayout above:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/eventContainerSub">
Both containers have the exact same name..eventContainerSub.
There is no eventContainer, change the view group to be the container as you planned..
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:id="#+id/event_container"
android:weightSum="100"
android:duplicateParentState="true">
and make sure the code is asking for the right Ids:
final LinearLayout eventContainerSub =
(LinearLayout) findViewById(R.layout.eventContainerSub);
final LinearLayout eventContainer =
(LinearLayout) findViewById(R.id.event_container);
I'd also suggest you first remove the SubContainer from the view if it got inflated, as that view already has a parent and you cannot attach the SubContainer to two parents.
Either leave the subcontainer from this file and create a new one, or remove from the parent and only then add to the ViewGroup you want.
Android layout replacing a view with another view on run time
Call removeView() on the child's parent first