List of usage examples for android.view ViewGroup setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:gov.wa.wsdot.android.wsdot.ui.trafficmap.socialmedia.twitter.TwitterFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_with_spinner_swipe_refresh, null); mRecyclerView = root.findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new TwitterItemAdapter(null); mRecyclerView.setAdapter(mAdapter);/*from w w w . j ava 2 s . co m*/ // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light); mEmptyView = root.findViewById(R.id.empty_list_view); Spinner spinner = root.findViewById(R.id.fragment_spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getContext(), R.array.twitter_accounts, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(this); viewModel = ViewModelProviders.of(this, viewModelFactory).get(TwitterViewModel.class); viewModel.getResourceStatus().observe(this, resourceStatus -> { if (resourceStatus != null) { switch (resourceStatus.status) { case LOADING: swipeRefreshLayout.setRefreshing(true); break; case SUCCESS: swipeRefreshLayout.setRefreshing(false); break; case ERROR: swipeRefreshLayout.setRefreshing(false); TextView t = (TextView) mEmptyView; t.setText(R.string.no_connection); mEmptyView.setVisibility(View.VISIBLE); Toast.makeText(getContext(), "connection error", Toast.LENGTH_SHORT).show(); } } }); viewModel.getTwitterPosts().observe(this, twitterItems -> { if (twitterItems != null) { mEmptyView.setVisibility(View.GONE); if (!twitterItems.isEmpty()) { mAdapter.setData(twitterItems); } else { TextView t = (TextView) mEmptyView; t.setText("tweets unavailable."); mEmptyView.setVisibility(View.VISIBLE); } } }); viewModel.refresh(); return root; }
From source file:gov.wa.wsdot.android.wsdot.ui.borderwait.BorderWaitSouthboundFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_list_with_swipe_refresh, null); mRecyclerView = root.findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new BorderWaitSouthboundFragment.BorderWaitAdapter(getActivity()); mRecyclerView.setAdapter(mAdapter);/*from ww w . j a va2 s. co m*/ mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity())); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light); swipeRefreshLayout.setRefreshing(true); viewModel = ViewModelProviders.of(this, viewModelFactory).get(BorderWaitViewModel.class); viewModel.init(BorderWaitViewModel.BorderDirection.SOUTHBOUND); viewModel.getResourceStatus().observe(this, resourceStatus -> { if (resourceStatus != null) { switch (resourceStatus.status) { case LOADING: swipeRefreshLayout.setRefreshing(true); break; case SUCCESS: swipeRefreshLayout.setRefreshing(false); break; case ERROR: swipeRefreshLayout.setRefreshing(false); Toast.makeText(this.getContext(), "connection error", Toast.LENGTH_LONG).show(); } } }); viewModel.getBorderWaits().observe(this, borderWaits -> { mBorderWaits.clear(); mBorderWaits = borderWaits; mAdapter.notifyDataSetChanged(); }); mEmptyView = root.findViewById(R.id.empty_list_view); return root; }
From source file:gov.wa.wsdot.android.wsdot.ui.mountainpasses.passitem.MountainPassItemCameraFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_with_spinner, null); mRecyclerView = (RecyclerView) root.findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new PassCameraImageAdapter(getActivity(), null); mRecyclerView.setAdapter(mAdapter);/* ww w . j a va 2 s . c om*/ mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity())); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mLoadingSpinner = root.findViewById(R.id.loading_spinner); mEmptyView = root.findViewById(R.id.empty_list_view); camerasArray = "[]"; viewModel = ViewModelProviders.of(this, viewModelFactory).get(MountainPassViewModel.class); viewModel.getPassFor(mPassId).observe(this, pass -> { if (pass != null) { camerasArray = pass.getCamera(); // Prepare the loader. Either re-connect with an existing one, // or start a new one. getLoaderManager().initLoader(0, null, this); } }); return root; }
From source file:gov.wa.wsdot.android.wsdot.ui.borderwait.BorderWaitNorthboundFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_list_with_swipe_refresh, null); mRecyclerView = root.findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new BorderWaitNorthboundFragment.BorderWaitAdapter(getActivity()); mRecyclerView.setAdapter(mAdapter);/*from w w w .j a v a 2 s . c om*/ mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity())); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light); swipeRefreshLayout.setRefreshing(true); viewModel = ViewModelProviders.of(this, viewModelFactory).get(BorderWaitViewModel.class); viewModel.init(BorderWaitViewModel.BorderDirection.NORTHBOUND); viewModel.getResourceStatus().observe(this, resourceStatus -> { if (resourceStatus != null) { switch (resourceStatus.status) { case LOADING: swipeRefreshLayout.setRefreshing(true); break; case SUCCESS: swipeRefreshLayout.setRefreshing(false); break; case ERROR: swipeRefreshLayout.setRefreshing(false); Toast.makeText(this.getContext(), "connection error", Toast.LENGTH_LONG).show(); } } }); viewModel.getBorderWaits().observe(this, borderWaits -> { if (borderWaits.size() > 0) { mBorderWaits.clear(); mBorderWaits = borderWaits; mAdapter.notifyDataSetChanged(); } }); mEmptyView = root.findViewById(R.id.empty_list_view); return root; }
From source file:gov.wa.wsdot.android.wsdot.ui.mountainpasses.MountainPassesFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_list_with_swipe_refresh, null); mRecyclerView = root.findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new MountainPassAdapter(getActivity()); mRecyclerView.setAdapter(mAdapter);//from ww w .j a va2 s. co m mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity())); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light); mEmptyView = root.findViewById(R.id.empty_list_view); mEmptyView.setVisibility(View.GONE); viewModel = ViewModelProviders.of(this, viewModelFactory).get(MountainPassViewModel.class); viewModel.getResourceStatus().observe(this, resourceStatus -> { if (resourceStatus != null) { switch (resourceStatus.status) { case LOADING: swipeRefreshLayout.setRefreshing(true); break; case SUCCESS: swipeRefreshLayout.setRefreshing(false); break; case ERROR: swipeRefreshLayout.setRefreshing(false); Toast.makeText(this.getContext(), "connection error", Toast.LENGTH_LONG).show(); } } }); viewModel.getPasses().observe(this, passes -> { mAdapter.setData(passes); }); return root; }
From source file:gov.wa.wsdot.android.wsdot.ui.traveltimes.TravelTimesFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_list_with_swipe_refresh, null); mRecyclerView = root.findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new TravelTimesAdapter(getActivity()); mRecyclerView.setAdapter(mAdapter);/*from ww w . j a va 2 s. c om*/ mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity())); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light); mEmptyView = root.findViewById(R.id.empty_list_view); viewModel = ViewModelProviders.of(this, viewModelFactory).get(TravelTimesViewModel.class); viewModel.getResourceStatus().observe(this, resourceStatus -> { if (resourceStatus != null) { switch (resourceStatus.status) { case LOADING: swipeRefreshLayout.setRefreshing(true); break; case SUCCESS: swipeRefreshLayout.setRefreshing(false); break; case ERROR: swipeRefreshLayout.setRefreshing(false); Toast.makeText(this.getContext(), "connection error", Toast.LENGTH_LONG).show(); } } }); viewModel.getQueryTravelTimes().observe(this, travelTimes -> { if (travelTimes != null) { if (travelTimes.size() == 0) { TextView t = (TextView) mEmptyView; if (!viewModel.getQueryTermValue().equals("")) { t.setText(R.string.no_matching_travel_times); } else { t.setText("travel times unavailable."); } mEmptyView.setVisibility(View.VISIBLE); } else { mEmptyView.setVisibility(View.GONE); } mAdapter.setData(new ArrayList<>(travelTimes)); } }); viewModel.setQueryTerm(""); return root; }
From source file:gov.wa.wsdot.android.wsdot.ui.ferries.FerriesRouteSchedulesFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_list_with_swipe_refresh, null); mRecyclerView = root.findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new RouteSchedulesAdapter(getActivity()); mRecyclerView.setAdapter(mAdapter);/* www. ja v a 2 s. c o m*/ mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity())); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light); mEmptyView = root.findViewById(R.id.empty_list_view); viewModel = ViewModelProviders.of(this, viewModelFactory).get(FerrySchedulesViewModel.class); viewModel.init(null); viewModel.getResourceStatus().observe(this, resourceStatus -> { if (resourceStatus != null) { switch (resourceStatus.status) { case LOADING: swipeRefreshLayout.setRefreshing(true); break; case SUCCESS: swipeRefreshLayout.setRefreshing(false); if (mAdapter.getItemCount() > 0) { mEmptyView.setVisibility(View.GONE); } break; case ERROR: swipeRefreshLayout.setRefreshing(false); if (mAdapter.getItemCount() > 0) { mEmptyView.setVisibility(View.GONE); } Toast.makeText(this.getContext(), "connection error", Toast.LENGTH_SHORT).show(); } } }); viewModel.getFerrySchedules().observe(this, schedules -> { mSchedule = schedules; mAdapter.notifyDataSetChanged(); }); return root; }
From source file:gov.wa.wsdot.android.wsdot.ui.ferries.departures.FerriesRouteSchedulesDayDeparturesFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { tf = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Roboto-Regular.ttf"); tfb = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Roboto-Bold.ttf"); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_route_schedules_day_departures, null); mRecyclerView = root.findViewById(R.id.my_recycler_view); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new DepartureTimesAdapter(getActivity(), null); mRecyclerView.setAdapter(mAdapter);/*from ww w . j av a 2 s . co m*/ mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity())); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light); mEmptyView = root.findViewById(R.id.empty_list_view); schedulesViewModel = ViewModelProviders.of(getActivity()).get(FerrySchedulesViewModel.class); terminalViewModel = ViewModelProviders.of(getActivity()).get(FerryTerminalViewModel.class); terminalViewModel.getResourceStatus().observe(this, resourceStatus -> { if (resourceStatus != null) { switch (resourceStatus.status) { case LOADING: swipeRefreshLayout.setRefreshing(true); break; case SUCCESS: swipeRefreshLayout.setRefreshing(false); break; case ERROR: swipeRefreshLayout.setRefreshing(false); Toast.makeText(this.getContext(), "connection error, can't update spaces", Toast.LENGTH_SHORT) .show(); } } }); terminalViewModel.getDepartureTimes().observe(this, sailingTimes -> { if (sailingTimes != null) { if (sailingTimes.size() != 0) { mEmptyView.setVisibility(View.GONE); } else { TextView t = (TextView) mEmptyView; t.setText(R.string.no_day_departures); mEmptyView.setVisibility(View.VISIBLE); } mAdapter.setData(new ArrayList<>(sailingTimes)); // Scroll to the first sailing time that hasn't already passed. if (terminalViewModel.getShouldScrollToCurrent()) { terminalViewModel.setScrollToCurrent(false); try { Date now = new Date(); for (int i = 0; i < sailingTimes.size(); i++) { if (now.before(sailingTimes.get(i).getDepartingTime())) { mRecyclerView.stopScroll(); ((LinearLayoutManager) mRecyclerView.getLayoutManager()) .scrollToPositionWithOffset(i, 0); i = sailingTimes.size(); } } } catch (Exception e) { MyLogger.crashlyticsLog("Ferries", "Error", "Auto scroll failed", 1); } } } }); terminalViewModel.getDepartureTimesAnnotations().observe(this, sailingAnnotations -> { if (sailingAnnotations != null) { annotations = new ArrayList<>(sailingAnnotations); mAdapter.notifyDataSetChanged(); } else { annotations.clear(); } }); terminalViewModel.forceRefreshVesselStatus(); return root; }
From source file:com.mobicage.rogerthat.plugins.friends.ServiceActionMenuActivity.java
@Override protected void onServiceBound() { L.d("ServiceActionMenuActivity onServiceBound()"); final Typeface faTypeFace = Typeface.createFromAsset(getAssets(), "FontAwesome.ttf"); final int defaultFirstRowTextColor = Color.parseColor("#646464"); final FriendsPlugin friendsPlugin = mService.getPlugin(FriendsPlugin.class); final ServiceMenu menu = friendsPlugin.getStore().getMenu(email, page); TableLayout menu_table = (TableLayout) findViewById(R.id.menu_table); int tableWidth = menu_table.getWidth(); for (int x = 0; x < 4; x++) { for (int y = 0; y < 3; y++) { android.view.ViewGroup cellLayout = (android.view.ViewGroup) findViewById( getResources().getIdentifier("menu_" + x + "x" + y, "id", getPackageName())); android.view.ViewGroup.LayoutParams lp = cellLayout.getLayoutParams(); lp.width = tableWidth / 4;//from w ww. j a v a2 s . c o m cellLayout.setLayoutParams(lp); Cell cell = new Cell(); cell.icon = (ImageView) cellLayout.findViewById(R.id.icon); cell.faIcon = (TextView) cellLayout.findViewById(R.id.fa_icon); cell.label = (TextView) cellLayout.findViewById(R.id.label); cells[x][y] = cell; if (y == 0) { cell.icon.setVisibility(View.GONE); cell.faIcon.setTypeface(faTypeFace); cell.faIcon.setTextColor(defaultFirstRowTextColor); switch (x) { case 0: cell.faIcon.setVisibility(View.VISIBLE); cell.faIcon.setText(R.string.fa_info); break; case 1: cell.faIcon.setVisibility(View.VISIBLE); cell.faIcon.setText(R.string.fa_envelope); break; case 2: cell.faIcon.setVisibility(View.INVISIBLE); cell.faIcon.setText(R.string.fa_phone); break; case 3: cell.faIcon.setVisibility(View.INVISIBLE); cell.faIcon .setText(CloudConstants.isYSAAA() ? R.string.fa_qrcode : R.string.fa_thumbs_o_up); break; default: break; } } } } for (int y = 0; y < 3; y++) { TableRow row = (TableRow) findViewById(getResources().getIdentifier("row" + y, "id", getPackageName())); tableRows[y] = row; } clearScreen(); populateScreen(menu); IntentFilter filter = new IntentFilter(FriendsPlugin.FRIEND_UPDATE_INTENT); filter.addAction(FriendsPlugin.FRIEND_REMOVED_INTENT); filter.addAction(FriendsPlugin.FRIEND_MARKED_FOR_REMOVAL_INTENT); filter.addAction(MessagingPlugin.NEW_MESSAGE_RECEIVED_INTENT); filter.addAction(MessagingPlugin.MESSAGE_PROCESSED_INTENT); filter.addAction(MessagingPlugin.MESSAGE_LOCKED_INTENT); filter.addAction(MessagingPlugin.MESSAGE_DIRTY_CLEANED_INTENT); filter.addAction(MessagingPlugin.THREAD_DELETED_INTENT); filter.addAction(MessagingPlugin.THREAD_RECOVERED_INTENT); filter.addAction(BrandingMgr.SERVICE_BRANDING_AVAILABLE_INTENT); filter.addAction(BrandingMgr.GENERIC_BRANDING_AVAILABLE_INTENT); filter.addAction(MessagingPlugin.MESSAGE_JSMFR_ERROR); registerReceiver(mBroadcastReceiver, filter); findViewById(R.id.navigation_bar_home_button).setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { Intent i = new Intent(ServiceActionMenuActivity.this, HomeActivity.class); i.setFlags(MainActivity.FLAG_CLEAR_STACK); startActivity(i); finish(); } }); }
From source file:mobi.cangol.mobile.navigation.DrawerMenuLayout.java
private void fitDecorChild(View view) { ViewGroup contentView = (ViewGroup) view.findViewById(R.id.actionbar_content_view); if (contentView != null) { ViewGroup decorChild = (ViewGroup) contentView.getChildAt(0); if (decorChild != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { WindowManager manager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) decorChild.getLayoutParams(); switch (manager.getDefaultDisplay().getRotation()) { case Surface.ROTATION_90: layoutParams.rightMargin = 0; break; case Surface.ROTATION_180: layoutParams.topMargin = 0; break; case Surface.ROTATION_270: layoutParams.leftMargin = 0; break; default: layoutParams.bottomMargin = 0; }//from w ww . j a v a 2 s.com decorChild.setLayoutParams(layoutParams); } } } }