List of usage examples for android.widget LinearLayout setBackgroundResource
@RemotableViewMethod public void setBackgroundResource(@DrawableRes int resid)
From source file:com.woodblockwithoutco.quickcontroldock.ui.ControlService.java
public void attachTemporaryView(Drawable icon, String appName) { LinearLayout l = new LinearLayout(getApplicationContext()); l.setGravity(Gravity.CENTER_VERTICAL); l.setOrientation(LinearLayout.HORIZONTAL); l.setPadding(NOTIFICATION_TOAST_PADDING_PX, NOTIFICATION_TOAST_PADDING_PX, NOTIFICATION_TOAST_PADDING_PX, NOTIFICATION_TOAST_PADDING_PX); l.setBackgroundResource(R.drawable.notification_toast_bg); TextView tv = new TextView(getApplicationContext()); tv.setGravity(Gravity.CENTER);/*from ww w .j a v a 2 s .c om*/ tv.setCompoundDrawablePadding(COMPOUND_DRAWABLE_PADDING_PX); tv.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); String notificationText = getString(R.string.notification_from) + "\n" + appName; tv.setText(notificationText); tv.setTextColor(COLOR_WHITE); l.addView(tv); Toast toast = new Toast(getApplicationContext()); toast.setView(l); toast.show(); }
From source file:org.apps8os.motivator.ui.MainActivity.java
/** * Showing the guide of the main sections in the application */// w w w. jav a2 s .c o m public void showHelp() { if (!mHelpIsVisible) { mHelpIsVisible = true; mViewPager.setCurrentItem(1); final FrameLayout contentRoot = (FrameLayout) findViewById(R.id.root_view); // Inflate the help overlay to the fragment. getLayoutInflater().inflate(R.layout.element_help_overlay, contentRoot, true); final TextView helpTitle = (TextView) contentRoot.findViewById(R.id.help_overlay_title); helpTitle.setText(getString(R.string.today_section)); final TextView helpText = (TextView) contentRoot.findViewById(R.id.help_overlay_subtitle); helpText.setText(getString(R.string.today_section_help)); final LinearLayout helpBackground = (LinearLayout) contentRoot.findViewById(R.id.help_text_background); helpBackground.setBackgroundResource(R.color.actionbar_green); ((Button) contentRoot.findViewById(R.id.help_overlay_button)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mViewPager.getCurrentItem() == 0) { final View helpOverlay = (View) contentRoot.findViewById(R.id.help_overlay); helpOverlay.animate().alpha(0f).setDuration(500).setListener(new AnimatorListenerAdapter() { // Set the visibility to gone when animation has ended. @Override public void onAnimationEnd(Animator animation) { helpOverlay.setVisibility(View.GONE); contentRoot.removeView(helpOverlay); } }); mViewPager.setCurrentItem(1); SharedPreferences.Editor editor = mPrefs.edit(); editor.putBoolean(SEEN_HELP, true); editor.commit(); mHelpIsVisible = false; } else if (mViewPager.getCurrentItem() == 1) { mViewPager.setCurrentItem(2); helpTitle.setText(getString(R.string.plan_section)); helpText.setText(getString(R.string.plan_section_help)); helpBackground.setBackgroundResource(R.color.actionbar_blue); } else { mViewPager.setCurrentItem(0); helpTitle.setText(getString(R.string.history_section)); helpText.setText(getString(R.string.history_section_help)); helpBackground.setBackgroundResource(R.color.actionbar_orange); ((Button) contentRoot.findViewById(R.id.help_overlay_button)) .setText(getString(R.string.ok)); } } }); } }
From source file:com.uzmap.pkg.uzmodules.uzBMap.mode.Billboard.java
@SuppressWarnings("deprecation") public View billboardView() { LinearLayout billboardLayout = new LinearLayout(context); LayoutParams layoutParams = null;/*ww w .j a v a2 s .co m*/ if (bgImg != null) { billboardLayout.setBackgroundDrawable(new BitmapDrawable(bgImg)); layoutParams = new LayoutParams(UZCoreUtil.dipToPix(width), UZCoreUtil.dipToPix(height)); } else { billboardLayout.setBackgroundResource(UZResourcesIDFinder.getResDrawableID("mo_bmap_popupmap")); layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, UZCoreUtil.dipToPix(height)); } billboardLayout.setLayoutParams(layoutParams); billboardLayout.setOrientation(LinearLayout.HORIZONTAL); if (getIconAlign().equals("left")) { if (iconStr != null && !iconStr.isEmpty()) billboardLayout.addView(icon()); billboardLayout.addView(titleLayout()); } else { billboardLayout.addView(titleLayout()); if (iconStr != null && !iconStr.isEmpty()) billboardLayout.addView(icon()); } return billboardLayout; }
From source file:com.uzmap.pkg.uzmodules.uzBMap.mode.Billboard.java
@SuppressWarnings("deprecation") public View billboardView(ImageView icon) { LinearLayout billboardLayout = new LinearLayout(context); LayoutParams layoutParams = null;/* ww w . j a v a 2 s .c om*/ if (bgImg != null) { billboardLayout.setBackgroundDrawable(new BitmapDrawable(bgImg)); layoutParams = new LayoutParams(UZCoreUtil.dipToPix(width), UZCoreUtil.dipToPix(height)); } else { billboardLayout.setBackgroundResource(UZResourcesIDFinder.getResDrawableID("mo_bmap_popupmap")); layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, UZCoreUtil.dipToPix(height)); } billboardLayout.setLayoutParams(layoutParams); billboardLayout.setOrientation(LinearLayout.HORIZONTAL); if (getIconAlign().equals("left")) { if (iconStr != null && !iconStr.isEmpty()) billboardLayout.addView(icon); billboardLayout.addView(titleLayout()); } else { billboardLayout.addView(titleLayout()); if (iconStr != null && !iconStr.isEmpty()) billboardLayout.addView(icon()); } return billboardLayout; }
From source file:lenidh.android.holochron.ui.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // Theme needs to be selected before super.onCreate. if (App.getThemePreference().equals(getString(R.string.pref_value_theme_dark)) || App.getThemePreference().equals(getString(R.string.pref_value_theme_classic))) { setTheme(R.style.AppTheme_Dark); }/*from ww w .ja v a 2 s . co m*/ super.onCreate(savedInstanceState); if (App.getThemePreference().equals(getString(R.string.pref_value_theme_classic))) { setContentView(R.layout.activity_main_classic); } else { setContentView(R.layout.activity_main); } /* state button */ this.btnState = (Button) this.findViewById(R.id.btnState); this.btnState.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onStartStop(); } }); /* extra button */ this.btnExtra = (Button) this.findViewById(R.id.btnExtra); this.btnExtra.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onResetRecord(); } }); // Configure dark theme. if (App.getThemePreference().equals(getString(R.string.pref_value_theme_dark))) { LinearLayout tile = (LinearLayout) this.findViewById(R.id.tile); View hView = this.findViewById(R.id.hSeparator); View vView = this.findViewById(R.id.vSeparator); View landSeparator = this.findViewById(R.id.landSeparator); tile.setBackgroundResource(R.drawable.tile_shape_dark); hView.setBackgroundResource(R.color.watch_button_separator_color_dark); vView.setBackgroundResource(R.color.watch_button_separator_color_dark); if (landSeparator != null) landSeparator.setBackgroundResource(android.R.color.white); this.btnState.setTextColor(getResources().getColor(android.R.color.white)); this.btnExtra.setTextColor(getResources().getColor(android.R.color.white)); } /* display */ this.display = (DigitalDisplay) this.findViewById(R.id.digitalDisplay1); /* elapsed time Adapter */ this.elapsedTimeArrayAdapter = new ElapsedTimeLapAdapter(this, App.getWatch().getLapContainer()); /* lap time Adapter */ LapTimeLapAdapter.SortOrder sortOrder = this.getLapTimeMode(); this.lapTimeArrayAdapter = new LapTimeLapAdapter(this, App.getWatch().getLapContainer(), sortOrder); /* lap pages */ // Find pager view. this.lapPager = (ViewPager) this.findViewById(R.id.lapPager); this.lapPager.setOnPageChangeListener(this); ArrayList<LapListFragment> pages = new ArrayList<LapListFragment>(); // Check if page was already created and create page if necessary. LapListFragment elapsedTimeListFragment = (LapListFragment) getSupportFragmentManager() .findFragmentByTag("android:switcher:" + lapPager.getId() + ":0"); if (elapsedTimeListFragment == null) elapsedTimeListFragment = new LapListFragment(); elapsedTimeListFragment.setListAdapter(this.elapsedTimeArrayAdapter); pages.add(elapsedTimeListFragment); // Check if page was already created and create page if necessary. this.lapTimeListFragment = (LapListFragment) getSupportFragmentManager() .findFragmentByTag("android:switcher:" + lapPager.getId() + ":1"); if (lapTimeListFragment == null) this.lapTimeListFragment = new LapListFragment(); this.lapTimeListFragment.setListAdapter(this.lapTimeArrayAdapter); pages.add(this.lapTimeListFragment); // Create the page adapter. LapPagerAdapter lapPagerAdapter = new LapPagerAdapter(getSupportFragmentManager()); lapPagerAdapter.setPages(pages); // Add page adapter to pager. this.lapPager.setAdapter(lapPagerAdapter); }
From source file:no.digipost.android.gui.content.ThreadPerTaskExecutor.java
public void createUI() { if (core == null) return;/*from w ww . ja va 2 s. co m*/ mPageNumberView = new TextView(this); mDocView = new MuPDFReaderView(this) { @Override protected void onMoveToChild(int i) { if (core == null) return; mPageNumberView.setText(String.format("%d / %d", i + 1, core.countPages())); if (searchModeOn) { if (currentVindow < i) { search(1); } else { search(-1); } currentVindow = i; } else { currentVindow = i; super.onMoveToChild(i); } } @Override public void onLongPress(MotionEvent e) { super.onLongPress(e); selectModeOn(); selectActionMode = startActionMode(selectActionModeCallback); } }; mDocView.setAdapter(new MuPDFPageAdapter(this, core)); mSearchTask = new SearchTask(this, core) { @Override protected void onTextFound(SearchTaskResult result) { SearchTaskResult.set(result); mDocView.setDisplayedViewIndex(result.pageNumber); mDocView.resetupChildren(); } }; mDocView.setLinksEnabled(true); LinearLayout layout = (LinearLayout) findViewById(R.id.pdf_layout); layout.addView(mDocView); layout.setBackgroundResource(R.drawable.document_background); }
From source file:org.nativescript.widgets.TabLayout.java
/** * Create a default view to be used for tabs. *///w w w. j a v a 2 s . c o m protected View createDefaultTabView(Context context, TabItemSpec tabItem) { float density = getResources().getDisplayMetrics().density; int padding = (int) (TAB_VIEW_PADDING_DIPS * density); LinearLayout ll = new LinearLayout(context); ll.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)); ll.setGravity(Gravity.CENTER); ll.setOrientation(LinearLayout.VERTICAL); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); ll.setBackgroundResource(outValue.resourceId); ImageView imgView = new ImageView(context); imgView.setScaleType(ScaleType.FIT_CENTER); LinearLayout.LayoutParams imgLP = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); imgLP.gravity = Gravity.CENTER; imgView.setLayoutParams(imgLP); TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setMaxWidth((int) (TEXT_MAX_WIDTH * density)); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setAllCaps(true); textView.setMaxLines(2); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView.setPadding(padding, 0, padding, 0); this.setupItem(ll, textView, imgView, tabItem); ll.addView(imgView); ll.addView(textView); return ll; }
From source file:no.digipost.android.gui.content.ThreadPerTaskExecutor.java
private void setupSearchView() { MenuItemCompat.setOnActionExpandListener(searchMenuItem, new MenuItemCompat.OnActionExpandListener() { @Override/* ww w . j av a 2s .com*/ public boolean onMenuItemActionExpand(MenuItem menuItem) { searchModeOn(); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem menuItem) { searchModeOff(); return true; } }); searchView = (android.support.v7.widget.SearchView) searchMenuItem.getActionView(); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String s) { if (!searchView.isIconified()) { searchView.setIconified(true); } searchMenuItem.collapseActionView(); search(1, s); return true; } @Override public boolean onQueryTextChange(String s) { if (SearchTaskResult.get() != null && !s.equals(SearchTaskResult.get().txt)) { SearchTaskResult.set(null); mDocView.resetupChildren(); } return true; } }); try { Field searchField = SearchView.class.getDeclaredField("mSearchButton"); searchField.setAccessible(true); android.widget.ImageView searchBtn = (android.widget.ImageView) searchField.get(searchView); searchBtn.setImageResource(R.drawable.white_search_48); searchField = SearchView.class.getDeclaredField("mSearchPlate"); searchField.setAccessible(true); LinearLayout searchPlate = (LinearLayout) searchField.get(searchView); AutoCompleteTextView searchTextView = (AutoCompleteTextView) searchPlate.getChildAt(0); searchTextView.setTextColor(getResources().getColor(R.color.white)); searchPlate.setBackgroundResource(R.drawable.search_background); searchTextView.setHintTextColor(getResources().getColor(R.color.searchbar_grey_hint)); searchView.setQueryHint(getString(R.string.pdf_search_document)); android.widget.ImageView searchViewClearButton = (android.widget.ImageView) searchPlate.getChildAt(1); searchViewClearButton.setImageResource(R.drawable.ic_clear_white); } catch (Exception e) { //Empty } }
From source file:org.apache.cordova.SplashScreenInternal.java
/** * Shows the splash screen over the full Activity */// ww w .jav a 2 s. c o m @SuppressWarnings("deprecation") private void showSplashScreen(final boolean hideAfterDelay) { final int splashscreenTime = preferences.getInteger("SplashScreenDelay", 3000); final int drawableId = preferences.getInteger("SplashDrawableId", 0); // If the splash dialog is showing don't try to show it again if (this.splashDialog != null && splashDialog.isShowing()) { return; } if (drawableId == 0 || (splashscreenTime <= 0 && hideAfterDelay)) { return; } cordova.getActivity().runOnUiThread(new Runnable() { public void run() { // Get reference to display Display display = cordova.getActivity().getWindowManager().getDefaultDisplay(); Context context = webView.getContext(); // Create the layout for the dialog LinearLayout root = new LinearLayout(context); root.setMinimumHeight(display.getHeight()); root.setMinimumWidth(display.getWidth()); root.setOrientation(LinearLayout.VERTICAL); // TODO: Use the background color of the webview's parent instead of using the // preference. root.setBackgroundColor(preferences.getInteger("backgroundColor", Color.BLACK)); root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0F)); root.setBackgroundResource(drawableId); // Create and show the dialog splashDialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar); // check to see if the splash screen should be full screen if ((cordova.getActivity().getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) { splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } splashDialog.setContentView(root); splashDialog.setCancelable(false); splashDialog.show(); // Set Runnable to remove splash screen just in case if (hideAfterDelay) { final Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { removeSplashScreen(); } }, splashscreenTime); } } }); }
From source file:com.gome.haoyuangong.views.MyViewPageIndicator.java
private void addTab(int index, CharSequence text, int iconResId) { final TabView tabView = new TabView(getContext()); tabView.mIndex = index;// w ww . java 2s. c o m tabView.setTag("tavView"); tabView.setId(index); // tabView.setFocusable(true); // tabView.setOnClickListener(mTabClickListener); tabView.setText(text); //tabView.setPadding(pointSize, 0, pointSize, 0); tabView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); tabView.setMaxLines(1); tabView.setGravity(Gravity.CENTER); XmlPullParser xrp = getResources().getXml(R.drawable.tab_button); try { ColorStateList csl = ColorStateList.createFromXml(getResources(), xrp); tabView.setTextColor(csl); } catch (Exception e) { } if (iconResId != 0) { //tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0); } FrameLayout.LayoutParams tabTvL = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); tabView.setLayoutParams(tabTvL); //measureView(tabView); LinearLayout layoutWraper1 = new LinearLayout(getContext()); LinearLayout.LayoutParams lp1 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1); layoutWraper1.setLayoutParams(lp1); layoutWraper1.setGravity(Gravity.CENTER); layoutWraper1.setFocusable(true); layoutWraper1.setOnClickListener(mTabClickListener); layoutWraper1.setPadding(0, 0, 0, 0); layoutWraper1.setBackgroundResource(R.drawable.tab_btn_red); FrameLayout frameLayout = new FrameLayout(getContext()); frameLayout.setTag("framelayout"); // FrameLayout.LayoutParams fl2 = new FrameLayout.LayoutParams(tabView.getMeasuredWidth() + padding, tabView.getMeasuredHeight()+ (int)(padding * 1.5)); FrameLayout.LayoutParams fl2 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); // frameLayout.setPadding(padding, padding, padding, padding); frameLayout.setLayoutParams(fl2); // frameLayout.addView(tabView); View hasNew = new View(getContext()); FrameLayout.LayoutParams hasNewL = new FrameLayout.LayoutParams(pointSize, pointSize); hasNew.setLayoutParams(hasNewL); hasNewL.gravity = Gravity.TOP | Gravity.RIGHT; hasNew.setBackgroundResource(R.drawable.shape_circle); FrameLayout tabTvframe = new FrameLayout(getContext()); FrameLayout.LayoutParams tabTvframeL = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); tabTvframeL.gravity = Gravity.CENTER; tabTvframe.setLayoutParams(tabTvframeL); tabTvframe.addView(tabView); tabTvframe.addView(hasNew); hasNew.setVisibility(View.GONE); frameLayout.addView(tabTvframe); layoutWraper1.addView(frameLayout); tabView.setTagView(hasNew); mTabLayout.addView(layoutWraper1, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1)); }