这就是我解决的方法,我在onCreateView回调中向视图添加了onLayoutChange侦听器,因此无论何时将其附加到视图并准备进行绘制,它都可以显示
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment final View view = inflater.inflate(R.layout.fragment_map_list, container, false); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { view.addonLayoutChangeListener(new View.onLayoutChangeListener() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { v.removeonLayoutChangeListener(this); toggleInformationView(view); } }); } return view; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)