daimajia / AndroidSwipeLayout

The Most Powerful Swipe Layout!
MIT License
12.38k stars 2.67k forks source link

Reflective setting of gravity throws exception, dumping stacktraces in logs #259

Open joprice opened 8 years ago

joprice commented 8 years ago

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)
Shafichariri commented 8 years ago

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

troyanas commented 7 years ago

Facing the same issue

troyanas commented 7 years ago

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 });

DevRamonLee commented 4 years ago

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.