List of usage examples for android.widget FrameLayout setBackground
public void setBackground(Drawable background)
From source file:com.vaporwarecorp.mirror.component.dottedgrid.DottedGridView.java
private void initializeLayout(Context context) { mViews = new LinkedHashSet<>(); FrameLayout gridLayout = new FrameLayout(context); gridLayout.setBackground(ContextCompat.getDrawable(context, R.drawable.bg_dotted_grid)); gridLayout.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT)); mBackground = new FrameLayout(context); mBackground.addView(gridLayout);/*w w w . ja v a 2 s.com*/ mBackground.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT)); mBackground.setBackground(ContextCompat.getDrawable(context, R.drawable.bg_solid_border)); mBackground.setVisibility(INVISIBLE); addView(mBackground); // now set the child clipping to false setClipChildren(false); }
From source file:org.namelessrom.devicecontrol.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // setup action bar final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from ww w .j a va 2s . com*/ toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mSubFragmentTitle == -1) { sSlidingMenu.toggle(true); } else { onCustomBackPressed(true); } } }); // setup material menu icon sMaterialMenu = new MaterialMenuIconToolbar(this, Color.WHITE, MaterialMenuDrawable.Stroke.THIN) { @Override public int getToolbarViewId() { return R.id.toolbar; } }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { sMaterialMenu.setNeverDrawTouch(true); } Utils.setupDirectories(); final FrameLayout container = (FrameLayout) findViewById(R.id.container); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { container.setBackground(null); } else { //noinspection deprecation container.setBackgroundDrawable(null); } final View v = getLayoutInflater().inflate(R.layout.menu_list, container, false); final ListView menuList = (ListView) v.findViewById(R.id.navbarlist); final LinearLayout menuContainer = (LinearLayout) v.findViewById(R.id.menu_container); // setup our static items menuContainer.findViewById(R.id.menu_prefs).setOnClickListener(this); menuContainer.findViewById(R.id.menu_about).setOnClickListener(this); sSlidingMenu = new SlidingMenu(this); sSlidingMenu.setMode(SlidingMenu.LEFT); sSlidingMenu.setShadowWidthRes(R.dimen.shadow_width); sSlidingMenu.setShadowDrawable(R.drawable.shadow_left); sSlidingMenu.setBehindWidthRes(R.dimen.slidingmenu_offset); sSlidingMenu.setFadeEnabled(true); sSlidingMenu.setFadeDegree(0.45f); sSlidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT); sSlidingMenu.setMenu(v); // setup touch mode MainActivity.setSwipeOnContent(DeviceConfiguration.get(this).swipeOnContent); // setup menu list setupMenuLists(); final MenuListArrayAdapter mAdapter = new MenuListArrayAdapter(this, R.layout.menu_main_list_item, mMenuEntries, mMenuIcons); menuList.setAdapter(mAdapter); menuList.setChoiceMode(ListView.CHOICE_MODE_SINGLE); menuList.setOnItemClickListener(this); loadFragmentPrivate(DeviceConstants.ID_ABOUT, false); getSupportFragmentManager().executePendingTransactions(); Utils.startTaskerService(); final String downgradePath = getFilesDir() + DeviceConstants.DC_DOWNGRADE; if (Utils.fileExists(downgradePath)) { if (!new File(downgradePath).delete()) { Logger.wtf(this, "Could not delete downgrade indicator file!"); } Toast.makeText(this, R.string.downgraded, Toast.LENGTH_LONG).show(); } if (DeviceConfiguration.get(this).dcFirstStart) { DeviceConfiguration.get(this).dcFirstStart = false; DeviceConfiguration.get(this).saveConfiguration(this); } }
From source file:com.mods.grx.settings.GrxSettingsActivity.java
private void update_nav_header_bg() { boolean color_bg = true; if (getResources().getBoolean(R.bool.allow_user_panel_header_bg)) { String nav_header_file = Common.IconsDir + File.separator + getString(R.string.gs_nav_header_bg_image_name); File f = new File(nav_header_file); if (f.exists()) { update_text_panel_header_bg(getString(R.string.gs_image)); Bitmap bitmap = GrxImageHelper.load_bmp_image(nav_header_file); if (bitmap != null) { FrameLayout header = (FrameLayout) mSVN.getHeaderView() .findViewById(R.id.navigation_header_container); if (header != null) { header.setBackground(new BitmapDrawable(bitmap)); color_bg = false;//from w ww . jav a 2s .co m } } } else update_text_panel_header_bg(getString(R.string.gs_default)); } if (color_bg) { FrameLayout header = (FrameLayout) mSVN.getHeaderView().findViewById(R.id.navigation_header_container); if (header != null) { TypedArray a = this.getTheme().obtainStyledAttributes(new int[] { R.attr.svn_nav_header_bg }); if (header != null) header.setBackgroundColor(a.getColor(0, 0)); a.recycle(); } } }
From source file:com.android.launcher3.Launcher.java
/** * Finds all the views we need and configure them properly. *///from ww w . j ava2s.c o m private void setupViews() { mLauncherView = findViewById(R.id.launcher); mDragLayer = (DragLayer) findViewById(R.id.drag_layer); mFocusHandler = mDragLayer.getFocusIndicatorHelper(); mWorkspace = (Workspace) mDragLayer.findViewById(R.id.workspace); mQsbContainer = mDragLayer.findViewById( mDeviceProfile.isVerticalBarLayout() ? R.id.workspace_blocked_row : R.id.qsb_container); mWorkspace.initParentViews(mDragLayer); mLauncherView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); // Setup the drag layer mDragLayer.setup(this, mDragController, mAllAppsController); // Setup the hotseat mHotseat = (Hotseat) findViewById(R.id.hotseat); if (mHotseat != null) { mHotseat.setOnLongClickListener(this); } // Setup the overview panel setupOverviewPanel(); setuphome(); // Setup the workspace mWorkspace.setHapticFeedbackEnabled(false); mWorkspace.setOnLongClickListener(this); mWorkspace.setup(mDragController); // Until the workspace is bound, ensure that we keep the wallpaper offset locked to the // default state, otherwise we will update to the wrong offsets in RTL mWorkspace.lockWallpaperToDefaultPage(); mDragController.addDragListener(mWorkspace); // Get the search/delete/uninstall bar mDropTargetBar = (DropTargetBar) mDragLayer.findViewById(R.id.drop_target_bar); // Setup Apps and Widgets mAppsView = (AllAppsContainerView) findViewById(R.id.apps_view); mWidgetsView = (WidgetsContainerView) findViewById(R.id.widgets_view); if (mLauncherCallbacks != null && mLauncherCallbacks.getAllAppsSearchBarController() != null) { mAppsView.setSearchBarController(mLauncherCallbacks.getAllAppsSearchBarController()); } else { mAppsView.setSearchBarController(new DefaultAppSearchController()); } // Setup the drag controller (drop targets have to be added in reverse order in priority) mDragController.setDragScoller(mWorkspace); mDragController.setScrollView(mDragLayer); mDragController.setMoveTarget(mWorkspace); mDragController.addDropTarget(mWorkspace); mDropTargetBar.setup(mDragController); if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) { mAllAppsController.setupViews(mAppsView, mHotseat, mWorkspace); } if (TestingUtils.MEMORY_DUMP_ENABLED) { TestingUtils.addWeightWatcher(this); } FrameLayout gBar = (FrameLayout) findViewById(R.id.g_bar); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { FrameLayout.LayoutParams gBarLayout = (FrameLayout.LayoutParams) gBar.getLayoutParams(); gBarLayout.width = Utils.getScreenXDimension(this) - Utils.getScreenXDimension(this) / 6; gBar.setLayoutParams(gBarLayout); } else { FrameLayout.LayoutParams gBarLayout = (FrameLayout.LayoutParams) gBar.getLayoutParams(); gBarLayout.width = Utils.getScreenYDimension(this) - Utils.getScreenYDimension(this) / 12; gBar.setLayoutParams(gBarLayout); } gBar.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { startSearch("", false, null, true); } }); ImageView gSearch = (ImageView) findViewById(R.id.g_search); gSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { startSearch("", false, null, true); } }); FrameLayout.LayoutParams gSearchLayout = (FrameLayout.LayoutParams) gSearch.getLayoutParams(); gSearchLayout.leftMargin = 30; gSearch.setLayoutParams(gSearchLayout); ImageView gSearchMic = (ImageView) findViewById(R.id.g_search_mic); if (IS_ALLOW_MIC) { gSearchMic.setVisibility(View.VISIBLE); gSearchMic.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); startActivityForResult(intent, RECOGNIZER_REQ_CODE); } }); } else { gSearchMic.setVisibility(View.GONE); } FrameLayout.LayoutParams gSearchMicLayout = (FrameLayout.LayoutParams) gSearchMic.getLayoutParams(); gSearchMicLayout.rightMargin = 30; gSearchMic.setLayoutParams(gSearchMicLayout); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (Utilities.isAllowNightModePrefEnabled(getApplicationContext())) { gBar.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.shape_night)); gSearch.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.g_icon_night)); gSearch.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.night_color)); gSearchMic .setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.mic_night)); gSearchMic.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.night_color)); } else { gBar.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.shape)); gSearch.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.g_icon)); gSearch.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), android.R.color.white)); gSearchMic.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.mic)); gSearchMic .setBackgroundColor(ContextCompat.getColor(getApplicationContext(), android.R.color.white)); } } if (!Utilities.isAllowPersisentSearchBarPrefEnabled(getApplicationContext())) { gBar.setVisibility(View.GONE); gSearch.setVisibility(View.GONE); gSearchMic.setVisibility(View.GONE); } else { gBar.setVisibility(View.VISIBLE); gSearch.setVisibility(View.VISIBLE); if (IS_ALLOW_MIC) { gSearchMic.setVisibility(View.VISIBLE); } else { gSearchMic.setVisibility(View.GONE); } } }