AndroidSwipeLayout icon indicating copy to clipboard operation
AndroidSwipeLayout copied to clipboard

Reflective setting of gravity throws exception, dumping stacktraces in logs

Open joprice opened this issue 9 years ago • 4 comments

I am using SwipeLayout with macroid in scala, so the SwipeLayout is created via code. It works great, but it fills the logs with exceptions, due to the following line:

https://github.com/daimajia/AndroidSwipeLayout/blob/d7a5759784c7399a1cbfe9b62c9fa6d0f257ab52/library/src/main/java/com/daimajia/swipe/SwipeLayout.java#L752

W/System.err(17183): java.lang.NoSuchFieldException: gravity
W/System.err(17183):    at java.lang.Class.getField(Class.java:1138)
W/System.err(17183):    at com.daimajia.swipe.SwipeLayout.addView(SwipeLayout.java:684)
W/System.err(17183):    at android.view.ViewGroup.addView(ViewGroup.java:4064)
W/System.err(17183):    at android.view.ViewGroup.addView(ViewGroup.java:4037)

joprice avatar Jan 09 '16 13:01 joprice

It also works great for me but like you I am getting the same error.

Shafichariri avatar Aug 08 '16 09:08 Shafichariri

Facing the same issue

troyanas avatar Aug 08 '17 10:08 troyanas

I have managed to over go this exception by adding Layout params with gravity when adding view to swipeLayout:

swipeLayout.AddView(result, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) { Gravity = GravityFlags.Center });

troyanas avatar Aug 08 '17 11:08 troyanas

I have managed to over go this exception by adding Layout params with gravity when adding view to swipeLayout:

swipeLayout.AddView(result, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) { Gravity = GravityFlags.Center });

I faced the same issue, much thank to you.

DevRamonLee avatar Dec 26 '19 10:12 DevRamonLee