How to animate & control Android PreferenceFragment screens? -


i have preferencefragment contents defined in xml. these contents include child preferencescreen. when click on preferencescreen, new screen rendered successfully, has no animation (it shows on screen, before material ripple finished on lollipop devices).

even worse, if had complex layout going on (for example, preferencefragment in tab on 1 side of screen) layout blown away , replaced full-screen fragment.

i suspect if find callback or event occurs when preferencescreen clicked, can solve both problems, don't know start.

i did slide in right-to-left animation of preferencefragment... extended preferencefragment , overridden oncreateview() this:

 @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {     view view = super.oncreateview(inflater, container, savedinstancestate);     animrelativelayout animrelativelayout = new animrelativelayout(getactivity());     relativelayout.layoutparams layoutparams = new relativelayout.layoutparams(viewgroup.layoutparams.match_parent, viewgroup.layoutparams.match_parent);     animrelativelayout.setlayoutparams(layoutparams);     animrelativelayout.addview(view);     return animrelativelayout; } 

where animrelativelayout.java is

public class animrelativelayout extends relativelayout {  private imovementlistener mmovementlistener;  public animrelativelayout(context context) {     super(context);     this.initmembers(); }  public animrelativelayout(context context, attributeset attrs) {     super(context, attrs);     this.initmembers(); }  public animrelativelayout(context context, attributeset attrs, int defstyle) {     super(context, attrs, defstyle);     this.initmembers(); }  private void initmembers() {     this.mmovementlistener = new simplemovementlistener(); }  public float getxfraction() {     final windowmanager wm = (windowmanager) getcontext().getsystemservice(context.window_service);     display display = wm.getdefaultdisplay();     point size = new point();     display.getsize(size);     int width = size.x;     return (width == 0) ? 0 : getx() / (float) width; }  public void setxfraction(float xfraction) {     final windowmanager wm = (windowmanager) getcontext().getsystemservice(context.window_service);     display display = wm.getdefaultdisplay();     point size = new point();     display.getsize(size);     int width = size.x;     this.mmovementlistener.onsetxfraction(xfraction);     setx((width > 0) ? (xfraction * width) : 0); }  public float getyfraction() {     final windowmanager wm = (windowmanager) getcontext().getsystemservice(context.window_service);     display display = wm.getdefaultdisplay();     point size = new point();     display.getsize(size);     int height = size.y;     return (height == 0) ? 0 : gety() / (float) height; }  public void setyfraction(float yfraction) {     final windowmanager wm = (windowmanager) getcontext().getsystemservice(context.window_service);     display display = wm.getdefaultdisplay();     point size = new point();     display.getsize(size);     int height = size.y;     this.mmovementlistener.onsetyfraction(yfraction);     sety((height > 0) ? (yfraction * height) : 0); }  public interface imovementlistener {     public void onsetxfraction(float pxfraction);      public void onsetyfraction(float pyfraction); }  private class simplemovementlistener implements imovementlistener {      @override     public void onsetxfraction(float pxfraction) {      }      @override     public void onsetyfraction(float pyfraction) {      } } 

and did this:

pfragmentmanager.begintransaction()             .setcustomanimations(                     r.animator.slide_in_right_to_left, r.animator.slide_out_right_to_left,                     r.animator.slide_in_left_to_right, r.animator.slide_out_left_to_right             )             .replace(r.id.fragment_container, fragment)             .commit(); 

and example r.animator.slide_in_right_to_left is:

<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android">     <objectanimator xmlns:android="http://schemas.android.com/apk/res/android"         android:duration="300"         android:propertyname="xfraction"         android:valuefrom="1.0"         android:valueto="0"         android:valuetype="floattype"/> </set> 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -