List of usage examples for android.view ViewGroup setPadding
public void setPadding(int left, int top, int right, int bottom)
From source file:Main.java
public static void setView(Activity activity, int id) { LayoutInflater layoutInflater = LayoutInflater.from(activity); setTranslucentStatus(activity);/*from w ww. jav a2 s .c o m*/ ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView().findViewById(android.R.id.content); int height = getStatusBarHeight(activity); ViewGroup linearLayout = (ViewGroup) layoutInflater.from(activity).inflate(id, null); linearLayout.setPadding(0, height, 0, 0); decorView.removeAllViews(); decorView.addView(linearLayout); }
From source file:Main.java
public static void setColorForSwipeBack(Activity activity, int color, int statusBarAlpha) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content)); contentView.setPadding(0, getStatusBarHeight(activity), 0, 0); contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha)); setTransparentForWindow(activity); }/*from ww w .j ava 2 s.c o m*/ }
From source file:com.gosuncn.core.util.view.StatusBarUtils.java
/** * ???/* w w w . java 2s. c o m*/ * * @param activity ?activity * @param color ?? * @param statusBarAlpha ??? */ public static void setColorForSwipeBack(Activity activity, int color, int statusBarAlpha) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content)); contentView.setPadding(0, getStatusBarHeight(activity), 0, 0); contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha)); setTransparentForWindow(activity); } }
From source file:com.gosuncn.core.util.view.StatusBarUtils.java
@TargetApi(Build.VERSION_CODES.KITKAT) private static void clearPreviousSetting(Activity activity) { ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); int count = decorView.getChildCount(); if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) { decorView.removeViewAt(count - 1); ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)) .getChildAt(0);//from ww w .jav a2 s. com rootView.setPadding(0, 0, 0, 0); } }
From source file:com.battlelancer.seriesguide.ui.EpisodeDetailsActivity.java
private void setupViews() { // get episode id final int episodeId = getIntent().getIntExtra(InitBundle.EPISODE_TVDBID, 0); if (episodeId == 0) { // nothing to display finish();//from w ww . j av a2 s .co m return; } // get show and season id, poster path final Cursor episode = getContentResolver().query( Episodes.buildEpisodeWithShowUri(String.valueOf(episodeId)), new String[] { Seasons.REF_SEASON_ID, Shows.POSTER, Shows.REF_SHOW_ID, Shows.TITLE }, null, null, null); if (episode == null || !episode.moveToFirst()) { // nothing to display if (episode != null) { episode.close(); } finish(); return; } setupActionBar(episode.getString(3)); // set show poster as background Utils.loadPosterBackground(this, (ImageView) findViewById(R.id.background), episode.getString(1)); mShowId = episode.getInt(2); mSeasonId = episode.getInt(0); episode.close(); // get episodes of season Constants.EpisodeSorting sortOrder = DisplaySettings.getEpisodeSortOrder(this); Cursor episodesOfSeason = getContentResolver().query( Episodes.buildEpisodesOfSeasonUri(String.valueOf(mSeasonId)), new String[] { Episodes._ID, Episodes.NUMBER, Episodes.SEASON }, null, null, sortOrder.query()); ArrayList<Episode> episodes = new ArrayList<>(); int startPosition = 0; if (episodesOfSeason != null) { int i = 0; while (episodesOfSeason.moveToNext()) { Episode ep = new Episode(); int curEpisodeId = episodesOfSeason.getInt(0); // look for episode to show initially if (curEpisodeId == episodeId) { startPosition = i; } ep.episodeId = curEpisodeId; ep.episodeNumber = episodesOfSeason.getInt(1); ep.seasonNumber = episodesOfSeason.getInt(2); episodes.add(ep); i++; } episodesOfSeason.close(); } // setup adapter EpisodePagerAdapter adapter = new EpisodePagerAdapter(this, getSupportFragmentManager(), episodes, false); // setup view pager ViewPager pager = (ViewPager) findViewById(R.id.pagerEpisodeDetails); pager.setAdapter(adapter); // setup tabs SlidingTabLayout tabs = (SlidingTabLayout) findViewById(R.id.tabsEpisodeDetails); tabs.setCustomTabView(R.layout.tabstrip_item, R.id.textViewTabStripItem); tabs.setSelectedIndicatorColors( getResources().getColor(Utils.resolveAttributeToResourceId(getTheme(), R.attr.colorAccent))); tabs.setBottomBorderColor(Utils.setColorAlpha(getResources() .getColor(Utils.resolveAttributeToResourceId(getTheme(), R.attr.sgColorTabStripUnderline)), 0x26)); tabs.setViewPager(pager); if (AndroidUtils.isKitKatOrHigher()) { // fix padding with translucent status bar // warning: status bar not always translucent (e.g. Nexus 10) // (using fitsSystemWindows would not work correctly with multiple views) SystemBarTintManager systemBarTintManager = new SystemBarTintManager(this); SystemBarTintManager.SystemBarConfig config = systemBarTintManager.getConfig(); ViewGroup contentContainer = (ViewGroup) findViewById(R.id.contentContainerEpisodeDetails); contentContainer.setPadding(0, config.getPixelInsetTop(false), 0, 0); } // set current item pager.setCurrentItem(startPosition, false); }
From source file:org.gateshipone.odyssey.viewitems.ListViewItem.java
/** * Base constructor to create a non section-type element. * * @param context The current context.// ww w.jav a 2 s . co m * @param showIcon If the icon of the item should be shown. It is not changeable after creation. * @param adapter The scroll speed adapter for cover loading. */ private ListViewItem(final Context context, final boolean showIcon, final ScrollSpeedAdapter adapter) { super(context, R.layout.listview_item_file, 0, 0, adapter); mTitleView = (TextView) findViewById(R.id.item_title); mSubtitleView = (TextView) findViewById(R.id.item_subtitle); mAdditionalSubtitleView = (TextView) findViewById(R.id.item_additional_subtitle); mIconView = (ImageView) findViewById(R.id.item_icon); if (showIcon) { mIconView.setVisibility(VISIBLE); ViewGroup basicItemLayout = (ViewGroup) findViewById(R.id.basic_listview_item); basicItemLayout.setPadding(0, 0, basicItemLayout.getPaddingRight(), 0); } else { mIconView.setVisibility(GONE); } }
From source file:jahirfiquitiva.iconshowcase.activities.AltWallpaperViewerActivity.java
private void showNotConnectedSnackBar() { Snackbar notConnectedSnackBar = Utils.snackbar(this, layout, getString(R.string.no_conn_title), Snackbar.LENGTH_LONG);//from w w w.j a v a2s . co m ViewGroup snackbarView = (ViewGroup) notConnectedSnackBar.getView(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { snackbarView.setPadding(snackbarView.getPaddingLeft(), snackbarView.getPaddingTop(), snackbarView.getPaddingRight(), Utils.getNavigationBarHeight(this)); } notConnectedSnackBar.show(); }
From source file:jahirfiquitiva.iconshowcase.activities.AltWallpaperViewerActivity.java
private void saveWallpaper(final Activity context, final String wallName, final MaterialDialog downloadDialog, final Bitmap result) { downloadDialog.setContent(context.getString(R.string.saving_wallpaper)); new Thread(new Runnable() { @Override//from w w w . jav a 2s. c o m public void run() { if (mPrefs.getDownloadsFolder() != null) { downloadsFolder = new File(mPrefs.getDownloadsFolder()); } else { downloadsFolder = new File(context.getString(R.string.walls_save_location, Environment.getExternalStorageDirectory().getAbsolutePath())); } //noinspection ResultOfMethodCallIgnored downloadsFolder.mkdirs(); final File destFile = new File(downloadsFolder, wallName + ".png"); String snackbarText; if (!destFile.exists()) { try { result.compress(Bitmap.CompressFormat.PNG, 100, new FileOutputStream(destFile)); snackbarText = context.getString(R.string.wallpaper_downloaded, destFile.getAbsolutePath()); } catch (final Exception e) { snackbarText = context.getString(R.string.error); } } else { snackbarText = context.getString(R.string.wallpaper_downloaded, destFile.getAbsolutePath()); } final String finalSnackbarText = snackbarText; context.runOnUiThread(new Runnable() { @Override public void run() { downloadDialog.dismiss(); Snackbar longSnackbar = Utils.snackbar(AltWallpaperViewerActivity.this, layout, finalSnackbarText, Snackbar.LENGTH_LONG); ViewGroup snackbarView = (ViewGroup) longSnackbar.getView(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { snackbarView.setPadding(snackbarView.getPaddingLeft(), snackbarView.getPaddingTop(), snackbarView.getPaddingRight(), Utils.getNavigationBarHeight(AltWallpaperViewerActivity.this)); } longSnackbar.show(); longSnackbar.setCallback(new Snackbar.Callback() { @Override public void onDismissed(Snackbar snackbar, int event) { super.onDismissed(snackbar, event); reshowFab(fab); setupFullScreen(); } }); } }); } }).start(); }
From source file:com.android.deskclock.stopwatch.StopwatchFragment.java
/** * Show or hide the list of laps.//from w ww. j av a2 s .c o m */ private void showOrHideLaps(boolean clearLaps) { final ViewGroup sceneRoot = (ViewGroup) getView(); if (sceneRoot == null) { return; } TransitionManager.beginDelayedTransition(sceneRoot); if (clearLaps) { mLapsAdapter.clearLaps(); } final boolean lapsVisible = mLapsAdapter.getItemCount() > 0; mLapsList.setVisibility(lapsVisible ? VISIBLE : GONE); if (Utils.isPortrait(getActivity())) { // When the lap list is visible, it includes the bottom padding. When it is absent the // appropriate bottom padding must be applied to the container. final Resources res = getResources(); final int bottom = lapsVisible ? 0 : res.getDimensionPixelSize(R.dimen.fab_height); final int top = sceneRoot.getPaddingTop(); final int left = sceneRoot.getPaddingLeft(); final int right = sceneRoot.getPaddingRight(); sceneRoot.setPadding(left, top, right, bottom); } }
From source file:com.wizardsofm.deskclock.stopwatch.StopwatchFragment.java
/** * Show or hide the list of laps./* w ww . j a v a2s .c o m*/ */ private void showOrHideLaps(boolean clearLaps) { final ViewGroup sceneRoot = (ViewGroup) getView(); if (sceneRoot == null) { return; } TransitionManager.beginDelayedTransition(sceneRoot); if (clearLaps) { mLapsAdapter.clearLaps(); } final boolean lapsVisible = mLapsAdapter.getItemCount() > 0; mLapsList.setVisibility(lapsVisible ? VISIBLE : GONE); if (Utils.isPortrait(getActivity())) { // When the lap list is visible, it includes the bottom padding. When it is absent the // appropriate bottom padding must be applied to the container. final Resources res = getResources(); final int bottom = lapsVisible ? 0 : res.getDimensionPixelSize(com.wizardsofm.deskclock.R.dimen.fab_height); final int top = sceneRoot.getPaddingTop(); final int left = sceneRoot.getPaddingLeft(); final int right = sceneRoot.getPaddingRight(); sceneRoot.setPadding(left, top, right, bottom); } }