你可以做这样的事情
swipeLayout.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_MOVE){
Log.i("INFO", "MOVE");
getActivity().getActionBar().setTitle("Swipe to refresh");
getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getActivity().getActionBar().setCustomView(R.layout.custom_title);
getActivity().getActionBar().setDisplayUseLogoEnabled(false);
}
return false;
}
});
custom_title.xml - 使您的文本居中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="my Title"
android:id="@+id/mytext"
android:textSize="18sp" />
</LinearLayout>
在你的 onRefresh 结束或不再听触摸时,将标题和徽标设置回来。