Android 安卓扩展框架布局。不能';找不到属性xFraction异常的setter/getter
我扩展了FrameLayout类,用于在片段转换上制作滑入滑出动画。我希望以编程方式获取xFraction值Android 安卓扩展框架布局。不能';找不到属性xFraction异常的setter/getter,android,animation,transitions,android-framelayout,Android,Animation,Transitions,Android Framelayout,我扩展了FrameLayout类,用于在片段转换上制作滑入滑出动画。我希望以编程方式获取xFraction值 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:src="@+drawable/logo" />
<com.example.helpers.CustomFrameLayout
android:id="@+id/fragment"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
</RelativeLayout>
单击按钮后启动动画时引发异常:
Can't find native method using JNI, use reflectionjava.lang.NoSuchMethodError: no method with name='setXFraction' signature='(F)V' in class Landroid/widget/RelativeLayout;
02-17 13:57:33.369: E/PropertyValuesHolder(12223): Couldn't find setter/getter for property xFraction with value type float
-我从那里得到了我的想法。但它不起作用。请帮助我您似乎试图在父级
RelativeLayout
上调用方法:setXFraction(),而不是在com.example.helpers.CustomFrameLayout上调用
您应该像这样获得对CustomFrameLayout
的引用(假设您已经有了对名为parentRelativeLayout
的父布局的引用):
现在,您可以在适当的引用上调用setXFraction()
,例如:
customFrameLayout.setXFraction(25.4);
无论您尝试为哪个视图设置动画,都应该使用setXFraction方法
如果扩展整个xml,它将检查相对布局中的setXFraction
我想getNativeLoginFr是提供您的视图,它正在膨胀整个xml
您只需将该帧布局充气即可使动画工作。public void onClick(视图v){parentAct.setTransaction(getFragmentManager().beginTransaction());parentAct.getTransaction().setCustomAnimations(R.anim.slide_从_right_到_screen,R.anim.slide_从_screen_到_left);parentAct.getTransaction().replace(R.id.fragment,parentAct.getNativeLoginFr());parentAct.getTransaction().commit();}-所以我不调用这个方法,它应该自己工作我的幻灯片从_right_到_screen.xml内容是-我在这里找到了答案。
CustomFrameLayout customFrameLayout = (CustomFrameLayout) parentRelativeLayout.findViewById(R.id.fragment);
customFrameLayout.setXFraction(25.4);