List of usage examples for android.widget LinearLayout setBackgroundColor
@RemotableViewMethod public void setBackgroundColor(@ColorInt int color)
From source file:com.krayzk9s.imgurholo.ui.AccountFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); Log.d("Username", username); ImgurHoloActivity activity = (ImgurHoloActivity) getActivity(); SharedPreferences settings = activity.getApiCall().settings; Log.d("SettingTitle", username); View view = inflater.inflate(R.layout.account_layout, container, false); mPullToRefreshLayout = (PullToRefreshLayout) view.findViewById(R.id.ptr_layout); ActionBarPullToRefresh.from(getActivity()) // Mark All Children as pullable .allChildrenArePullable()/*from www . j a v a 2 s.c om*/ // Set the OnRefreshListener .listener(this) // Finally commit the setup to our PullToRefreshLayout .setup(mPullToRefreshLayout); LinearLayout header = (LinearLayout) view.findViewById(R.id.header); if (settings.getString("theme", MainActivity.HOLO_LIGHT).equals(MainActivity.HOLO_LIGHT)) header.setBackgroundColor(0xFFCCCCCC); biography = (TextView) view.findViewById(R.id.biography); TextView usernameText = (TextView) view.findViewById(R.id.username); usernameText.setText(username); created = (TextView) view.findViewById(R.id.created); reputation = (TextView) view.findViewById(R.id.reputation); mDrawerList = (ListView) view.findViewById(R.id.account_list); mMenuList = getResources().getStringArray(R.array.accountMenu); adapter = new ArrayAdapter<String>(view.getContext(), R.layout.drawer_list_item, mMenuList); mDrawerList.setAdapter(adapter); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); if (savedInstanceState == null) { getAccount(); } return view; }
From source file:org.anurag.file.quest.GraphAnalysis.java
/** * restyles the system UI like status bar or navigation bar if present.... *//*from w w w . ja va 2 s . c o m*/ private void init_system_ui() { // TODO Auto-generated method stub if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return; SystemBarTintManager tint = new SystemBarTintManager(GraphAnalysis.this); tint.setStatusBarTintEnabled(true); tint.setStatusBarTintColor(Constants.COLOR_STYLE); SystemBarConfig conf = tint.getConfig(); boolean hasNavBar = conf.hasNavigtionBar(); if (hasNavBar) { tint.setNavigationBarTintEnabled(true); tint.setNavigationBarTintColor(Constants.COLOR_STYLE); } LinearLayout main = (LinearLayout) findViewById(R.id.main); main.setPadding(0, getStatusBarHeight(), 0, hasNavBar ? getNavigationBarHeight() : 0); main.setBackgroundColor(Constants.COLOR_STYLE); }
From source file:com.tmall.ultraviewpager.sample.UltraPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(container.getContext()) .inflate(R.layout.layout_child, null); //new LinearLayout(container.getContext()); TextView textView = (TextView) linearLayout.findViewById(R.id.pager_textview); textView.setText(position + ""); linearLayout.setId(R.id.item_id);/*w w w .jav a 2s . co m*/ switch (position) { case 0: linearLayout.setBackgroundColor(Color.parseColor("#2196F3")); break; case 1: linearLayout.setBackgroundColor(Color.parseColor("#673AB7")); break; case 2: linearLayout.setBackgroundColor(Color.parseColor("#009688")); break; case 3: linearLayout.setBackgroundColor(Color.parseColor("#607D8B")); break; case 4: linearLayout.setBackgroundColor(Color.parseColor("#F44336")); break; } container.addView(linearLayout); // linearLayout.getLayoutParams().width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 180, container.getContext().getResources().getDisplayMetrics()); // linearLayout.getLayoutParams().height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 400, container.getContext().getResources().getDisplayMetrics()); return linearLayout; }
From source file:com.near.chimerarevo.fragments.ProductFragment.java
private void addRow(String key, String val, int i) { LinearLayout ll = new LinearLayout(getActivity()); ll.setOrientation(LinearLayout.HORIZONTAL); ll.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); if (i % 2 == 1) ll.setBackgroundColor(getResources().getColor(android.R.color.white)); TextView tv1 = new TextView(getActivity()); TextView tv2 = new TextView(getActivity()); tv1.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f)); tv2.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f)); tv1.setPadding(20, 10, 0, 10);//from ww w . j a va2 s . c o m tv2.setPadding(0, 10, 20, 10); tv1.setTypeface(Typeface.createFromAsset(getActivity().getAssets(), "roboto_condensed.ttf")); tv2.setTypeface(Typeface.createFromAsset(getActivity().getAssets(), "roboto_light.ttf")); tv1.setTextSize(16); tv2.setTextSize(15); tv1.setText(key); tv2.setText(val); ll.addView(tv1); ll.addView(tv2); lay.addView(ll); }
From source file:org.anurag.file.quest.FileProperties.java
/** * restyles the system UI like status bar or navigation bar if present.... */// w ww. j a v a 2 s .c o m private void init_system_ui() { // TODO Auto-generated method stub if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return; SystemBarTintManager tint = new SystemBarTintManager(FileProperties.this); tint.setStatusBarTintEnabled(true); tint.setStatusBarTintColor(Constants.COLOR_STYLE); SystemBarConfig conf = tint.getConfig(); boolean hasNavBar = conf.hasNavigtionBar(); if (hasNavBar) { tint.setNavigationBarTintEnabled(true); tint.setNavigationBarTintColor(Constants.COLOR_STYLE); } LinearLayout main = (LinearLayout) findViewById(R.id.main); main.setBackgroundColor(Constants.COLOR_STYLE); main.setPadding(0, getStatusBarHeight(), 0, hasNavBar ? getNavigationBarHeight() : 0); }
From source file:de.gebatzens.sia.fragment.FirstUseFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.fu_card, container, false); ImageView i = (ImageView) layout.findViewById(R.id.fu_image); TextView tvhead = (TextView) layout.findViewById(R.id.fu_header); TextView tvsub = (TextView) layout.findViewById(R.id.fu_text); switch (mPage) { case 0:/*from w w w . jav a 2 s . c om*/ color = Color.parseColor("#1976D2"); layout.setBackgroundColor(color); i.setImageResource(R.drawable.fu_device); tvhead.setText(R.string.fu_firstpage_title); tvsub.setText(R.string.fu_firstpage_content); break; case 1: color = Color.parseColor("#F4511E"); layout.setBackgroundColor(color); i.setImageResource(R.drawable.fu_overview); tvhead.setText(R.string.fu_secondpage_title); tvsub.setText(R.string.fu_secondpage_content); break; case 2: color = Color.parseColor("#43A047"); layout.setBackgroundColor(color); i.setImageResource(R.drawable.fu_filter); tvhead.setText(R.string.fu_thirdpage_title); tvsub.setText(R.string.fu_thirdpage_content); break; case 3: color = Color.parseColor("#d32f2f"); layout.setBackgroundColor(color); i.setImageResource(R.drawable.fu_exam); tvhead.setText(R.string.fu_fifthpage_title); tvsub.setText(R.string.fu_fifthpage_content); break; case 4: color = Color.parseColor("#00ACC1"); layout.setBackgroundColor(color); i.setImageResource(R.drawable.fu_more); tvhead.setText(R.string.fu_fourthpage_title); tvsub.setText(R.string.fu_fourthpage_content); break; case 5: color = Color.parseColor("#8BC34A"); layout.setBackgroundColor(color); i.setImageResource(R.drawable.fu_finish); tvhead.setText(R.string.fu_sixth_title); tvsub.setText(R.string.fu_sixth_content); break; } return layout; }
From source file:monakhv.android.samlib.MainActivity.java
@Override public void onCreate(Bundle icicle) { settings = new SettingsHelper(this); setTheme(settings.getTheme());/* w w w . ja va 2 s.c o m*/ super.onCreate(icicle); setContentView(R.layout.main_twopane); Bundle bundle = getIntent().getExtras(); String clean = null; if (bundle != null) { clean = bundle.getString(CLEAN_NOTIFICATION); } if (clean != null) { CleanNotificationData.start(this); bundle = null; } handler = new Handler(); SettingsHelper.addAuthenticator(this.getApplicationContext()); books = (BookListFragment) getSupportFragmentManager().findFragmentById(R.id.listBooksFragment); listHelper = (AuthorListFragment) getSupportFragmentManager().findFragmentById(R.id.listAuthirFragment); pane = (SlidingPaneLayout) findViewById(R.id.pane); pane.setPanelSlideListener(this); pane.setParallaxDistance(10); listHelper.setHasOptionsMenu(true); ActivityUtils.setShadow(pane); LinearLayout pane2 = (LinearLayout) findViewById(R.id.pane2); pane2.setBackgroundColor(getResources().getColor(settings.getBgColor())); //pane2.setBackgroundColor(getResources().getColor(R.color.BLACK)); // pane2.setBackgroundColor(getResources().getColor(R.color.WHITE)); isOpen = true; //use here bundle but not icicle !! if (bundle != null) { Log.i(DEBUG_TAG, "Restore state"); onRestoreInstanceState(bundle); } else { Log.i(DEBUG_TAG, "Make initial state"); onTitleChange(getString(R.string.app_name)); } //Ugly hack to make sure open pan on application startup handler.postDelayed(new Runnable() { public void run() { Log.d(DEBUG_TAG, "delay open"); logPaneDetails(); pane.openPane(); } }, TIME_BEFORE_OPEN_MILLI); }
From source file:org.quantumbadger.redreader.activities.InboxListingActivity.java
@Override public void onCreate(Bundle savedInstanceState) { PrefsUtility.applyTheme(this); super.onCreate(savedInstanceState); final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); final boolean solidblack = PrefsUtility.appearance_solidblack(this, sharedPreferences) && PrefsUtility.appearance_theme(this, sharedPreferences) == PrefsUtility.AppearanceTheme.NIGHT; getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); final String title; isModmail = getIntent() != null && getIntent().getBooleanExtra("modmail", false); if (!isModmail) { title = getString(R.string.mainmenu_inbox); } else {// w w w . j av a2 s.co m title = getString(R.string.mainmenu_modmail); } OptionsMenuUtility.fixActionBar(this, title); headerItems = PrefsUtility.appearance_comment_header_items(this, sharedPreferences); headerItems.remove(PrefsUtility.AppearanceCommentHeaderItems.SCORE); final LinearLayout outer = new LinearLayout(this); outer.setOrientation(android.widget.LinearLayout.VERTICAL); if (solidblack) { outer.setBackgroundColor(Color.BLACK); } loadingView = new LoadingView(this, getString(R.string.download_waiting), true, true); notifications = new LinearLayout(this); notifications.setOrientation(android.widget.LinearLayout.VERTICAL); notifications.addView(loadingView); final ListView lv = new ListView(this); lv.setSmoothScrollbarEnabled(false); lv.setVerticalFadingEdgeEnabled(false); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final Object item = lv.getAdapter().getItem(position); if (item != null && item instanceof RedditPreparedInboxItem) { ((RedditPreparedInboxItem) item).handleInboxClick(InboxListingActivity.this); } } }); adapter = new InboxListingAdapter(this, this); lv.setAdapter(adapter); registerForContextMenu(lv); outer.addView(notifications); outer.addView(lv); makeFirstRequest(this); setContentView(outer); }
From source file:ovh.ice.icecons.MainActivity.java
private void createLayout() { // main centered layout LinearLayout.LayoutParams smallLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f); float scale = IceScreenUtils.densityScale(getApplicationContext()); ViewGroup.LayoutParams buttonParams = new ViewGroup.LayoutParams(Math.round(48 * scale), Math.round(48 * scale)); LinearLayout frameLayout = new LinearLayout(this); frameLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); frameLayout.setBackgroundColor(0xffffffff); frameLayout.setGravity(Gravity.CENTER); setContentView(frameLayout);/*from w ww.j av a 2 s . c o m*/ LinearLayout baseLayout = new LinearLayout(this); baseLayout.setOrientation(LinearLayout.VERTICAL); baseLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT)); baseLayout.setGravity(Gravity.LEFT); frameLayout.addView(baseLayout); // wallpaper button LinearLayout wallpaperLayout = new LinearLayout(this); wallpaperLayout.setOrientation(LinearLayout.HORIZONTAL); wallpaperLayout.setLayoutParams(smallLayoutParams); wallpaperLayout.setGravity(Gravity.CENTER_VERTICAL); baseLayout.addView(wallpaperLayout); LinearLayout wallpaperClickLayout = new LinearLayout(this); wallpaperClickLayout.setOrientation(LinearLayout.HORIZONTAL); wallpaperClickLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); wallpaperClickLayout.setGravity(Gravity.CENTER); wallpaperLayout.addView(wallpaperClickLayout); wallpaperClickLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { wallpaperPicker(v); } }); Button wallpaperButton = new Button(this); wallpaperButton.setLayoutParams(buttonParams); wallpaperButton.setBackground( new BitmapDrawable(getResources(), IceImageUtils.bitmapLoad(getApplicationContext().getResources(), R.drawable.ic_wallpaper_button, Math.round(48 * scale), Math.round(48 * scale)))); wallpaperClickLayout.addView(wallpaperButton); TextView wallpaperText = new TextView(this); wallpaperText.setText("wallpapers"); wallpaperText.setTextSize(24); wallpaperText.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark)); wallpaperText.setPadding(64, 64, 64, 64); wallpaperClickLayout.addView(wallpaperText); // icon view button LinearLayout iconLayout = new LinearLayout(this); iconLayout.setOrientation(LinearLayout.HORIZONTAL); iconLayout.setLayoutParams(smallLayoutParams); iconLayout.setGravity(Gravity.CENTER_VERTICAL); baseLayout.addView(iconLayout); LinearLayout iconClickLayout = new LinearLayout(this); iconClickLayout.setOrientation(LinearLayout.HORIZONTAL); iconClickLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); iconClickLayout.setGravity(Gravity.CENTER); iconLayout.addView(iconClickLayout); iconClickLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { iconView(v); } }); Button iconButton = new Button(this); iconButton.setLayoutParams(buttonParams); iconButton.setBackground( new BitmapDrawable(getResources(), IceImageUtils.bitmapLoad(getApplicationContext().getResources(), R.drawable.ic_icon_button, Math.round(48 * scale), Math.round(48 * scale)))); iconClickLayout.addView(iconButton); TextView iconText = new TextView(this); iconText.setText("view icons"); iconText.setTextSize(24); iconText.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark)); iconText.setPadding(64, 64, 64, 64); iconClickLayout.addView(iconText); // source code button LinearLayout sourceLayout = new LinearLayout(this); sourceLayout.setOrientation(LinearLayout.HORIZONTAL); sourceLayout.setLayoutParams(smallLayoutParams); sourceLayout.setGravity(Gravity.CENTER_VERTICAL); baseLayout.addView(sourceLayout); LinearLayout sourceClickLayout = new LinearLayout(this); sourceClickLayout.setOrientation(LinearLayout.HORIZONTAL); sourceClickLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); sourceClickLayout.setGravity(Gravity.CENTER); sourceLayout.addView(sourceClickLayout); sourceClickLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { gitLink(v); } }); Button sourceButton = new Button(this); sourceButton.setLayoutParams(buttonParams); sourceButton.setBackground( new BitmapDrawable(getResources(), IceImageUtils.bitmapLoad(getApplicationContext().getResources(), R.drawable.ic_source_button, Math.round(48 * scale), Math.round(48 * scale)))); sourceClickLayout.addView(sourceButton); TextView sourceText = new TextView(this); sourceText.setText("source code"); sourceText.setTextSize(24); sourceText.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark)); sourceText.setPadding(64, 64, 64, 64); sourceClickLayout.addView(sourceText); // license button LinearLayout aboutLayout = new LinearLayout(this); aboutLayout.setOrientation(LinearLayout.HORIZONTAL); aboutLayout.setLayoutParams(smallLayoutParams); aboutLayout.setGravity(Gravity.CENTER_VERTICAL); baseLayout.addView(aboutLayout); LinearLayout aboutClickLayout = new LinearLayout(this); aboutClickLayout.setOrientation(LinearLayout.HORIZONTAL); aboutClickLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); aboutClickLayout.setGravity(Gravity.CENTER); aboutLayout.addView(aboutClickLayout); aboutClickLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { licenseShow(v); } }); Button aboutButton = new Button(this); aboutButton.setLayoutParams(buttonParams); aboutButton.setBackground( new BitmapDrawable(getResources(), IceImageUtils.bitmapLoad(getApplicationContext().getResources(), R.drawable.ic_license_button, Math.round(48 * scale), Math.round(48 * scale)))); aboutClickLayout.addView(aboutButton); TextView aboutText = new TextView(this); aboutText.setText("license"); aboutText.setTextSize(24); aboutText.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark)); aboutText.setPadding(64, 64, 64, 64); aboutClickLayout.addView(aboutText); }
From source file:com.nextgis.mobile.fragment.LayersFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_layers, container, false); LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.action_space); if (null != linearLayout) { linearLayout.setBackgroundColor(ControlHelper.getColor(view.getContext(), R.attr.colorPrimary)); }/*from w w w. j a v a2s .c o m*/ mSyncButton = (ImageButton) view.findViewById(R.id.sync); mNewLayer = (ImageButton) view.findViewById(R.id.new_layer); mNewLayer.setOnClickListener(this); mInfoText = (TextView) view.findViewById(R.id.info); setupSyncOptions(); updateInfo(); return view; }