List of usage examples for android.widget LinearLayout setBackgroundColor
@RemotableViewMethod public void setBackgroundColor(@ColorInt int color)
From source file:com.intel.xdk.display.Display.java
@JavascriptInterface public void startAR() { arView = CameraPreview.newInstance(activity.getApplicationContext()); arView.setVisibility(View.INVISIBLE); arView.height = 100;//w w w . j av a 2 s .c o m arView.width = 100; //no way to get current background color? arView.setBackgroundColor(Color.TRANSPARENT); SurfaceHolder sfhTrackHolder = arView.getHolder(); sfhTrackHolder.setFormat(PixelFormat.TRANSPARENT); sfhTrackHolder.setKeepScreenOn(true); sfhTrackHolder.setFixedSize(100, 100); activity.runOnUiThread(new Runnable() { public void run() { //activity.addContentView(arView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, 0.0F)); //activity.addContentView(arView, new LinearLayout.LayoutParams(400, 500, 0.0F)); ViewGroup rootView = (ViewGroup) webView.getParent().getParent(); rootView.addView(arView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); rootView.bringChildToFront((View) webView.getParent()); arView.setVisibility(View.VISIBLE); arView.showCamera(); webView.bringToFront(); webView.setBackgroundColor(0x00000000); LinearLayout ll = (LinearLayout) webView.getParent(); ll.setBackgroundColor(0x00000000); View activityView = activity.getCurrentFocus(); } }); }
From source file:com.krg.ParallaxScrollView.sample.PagerViewBackgroundActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create ParallaxScrollView, which will eventually be the container for everything. ParallaxScrollView parallaxScrollView = new ParallaxScrollView(this); parallaxScrollView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // Create the Background View, a ViewPager. ViewPager backgroundViewPager = new ViewPager(this); backgroundViewPager.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 600)); ImageAdapter adapter = new ImageAdapter(this); backgroundViewPager.setAdapter(adapter); // Create the Contents View. LinearLayout contentView = new LinearLayout(this); contentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); contentView.setBackgroundColor(0xffffffff); int padding = getResources().getDimensionPixelSize(R.dimen.content_padding); contentView.setPadding(padding, padding, padding, padding); TextView textView = new TextView(this); textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView.setText(R.string.starry_night); float textSize = getResources().getDimension(R.dimen.content_text_size); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); contentView.addView(textView);//from w w w .ja v a2 s.c o m // Make the ParallaxScrollView aware of the Background, Content, and Header Views, and set the content of // this view to the ParallaxScrollView. parallaxScrollView.setBackgroundView(backgroundViewPager); parallaxScrollView.setContentView(contentView); setContentView(parallaxScrollView); }
From source file:drawnzer.anurag.kollosal.KollosalPlayer.java
private void changeColor(int newColor) { //MusicFragment.getSlideLayout().setBackgroundColor(newColor); //pagerSlideTab.setIndicatorColor(getResources().getColor(R.color.semi_white)); RelativeLayout ml = (RelativeLayout) findViewById(R.id.main_ui); ml.setBackgroundColor(newColor);//from w w w .ja v a 2 s .com LinearLayout listLayout = (LinearLayout) findViewById(R.id.lists_layout); listLayout.setBackgroundColor(newColor); ColorDrawable color = new ColorDrawable(newColor); lsMenu.setDivider(color); lsTheme.setDivider(color); Drawable colorDrawable = new ColorDrawable(newColor); actionBar.setBackgroundDrawable(colorDrawable); // http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowTitleEnabled(true); currentColor = newColor; }
From source file:net.ustyugov.jtalk.activity.muc.Muc.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); service = JTalkService.getInstance(); setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark); setTitle(R.string.MUC);// w w w . j a v a 2 s . c o m getActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.paged_activity); LinearLayout linear = (LinearLayout) findViewById(R.id.linear); linear.setBackgroundColor(Colors.BACKGROUND); MainPageAdapter adapter = new MainPageAdapter(mPages); LayoutInflater inflater = LayoutInflater.from(this); Cursor cursor = service.getContentResolver().query(JTalkProvider.ACCOUNT_URI, null, AccountDbHelper.ENABLED + " = '" + 1 + "'", null, null); if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst(); do { final String account = cursor.getString(cursor.getColumnIndex(AccountDbHelper.JID)).trim(); View page = inflater.inflate(R.layout.list_activity, null); page.setTag(account); mPages.add(page); ListView list = (ListView) page.findViewById(R.id.list); list.setDividerHeight(0); list.setCacheColorHint(0x00000000); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { RosterItem item = (RosterItem) parent.getItemAtPosition(position); String name = item.getName(); String account = item.getAccount(); if (item.isGroup()) { if (item.isCollapsed()) { while (service.getCollapsedGroups().contains(name)) service.getCollapsedGroups().remove(name); item.setCollapsed(false); } else { service.getCollapsedGroups().add(name); item.setCollapsed(true); } updateList(); } else if (item.isEntry()) { RosterEntry re = item.getEntry(); String jid = re.getUser(); Intent i = new Intent(Muc.this, Chat.class); i.putExtra("account", account); i.putExtra("jid", jid); startActivity(i); } else if (item.isMuc()) { Intent i = new Intent(Muc.this, Chat.class); i.putExtra("account", account); i.putExtra("jid", item.getName()); startActivity(i); } } }); list.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) { RosterItem item = (RosterItem) parent.getItemAtPosition(position); if (item.isGroup()) { // } else if (item.isEntry()) { String j = item.getEntry().getUser(); String group = StringUtils.parseBareAddress(j); String nick = StringUtils.parseResource(j); MucDialogs.userMenu(Muc.this, item.getAccount(), group, nick); } else if (item.isMuc()) { MucDialogs.roomMenu(Muc.this, item.getAccount(), item.getName()); } return true; } }); MucRosterAdapter mra = new MucRosterAdapter(this, account); list.setAdapter(mra); adapters.add(mra); } while (cursor.moveToNext()); cursor.close(); } mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(adapter); mPager.setCurrentItem(0); TitlePageIndicator mTitleIndicator = (TitlePageIndicator) findViewById(R.id.indicator); mTitleIndicator.setTextColor(0xFF555555); mTitleIndicator.setViewPager(mPager); }
From source file:net.ustyugov.jtalk.activity.muc.MucUsers.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); String group = getIntent().getStringExtra("group"); account = getIntent().getStringExtra("account"); muc = JTalkService.getInstance().getConferencesHash(account).get(group); setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark); setContentView(R.layout.paged_activity); setTitle(R.string.Users);/*from w w w . j ava2 s . com*/ getActionBar().setDisplayHomeAsUpEnabled(true); LinearLayout chat_linear = (LinearLayout) findViewById(R.id.linear); chat_linear.setBackgroundColor(Colors.BACKGROUND); account = getIntent().getExtras().getString("account"); LayoutInflater inflater = LayoutInflater.from(MucUsers.this); View ownersPage = inflater.inflate(R.layout.muc_users_page, null); View adminsPage = inflater.inflate(R.layout.muc_users_page, null); View membersPage = inflater.inflate(R.layout.muc_users_page, null); View outcastsPage = inflater.inflate(R.layout.muc_users_page, null); ownersPage.setTag("Owners"); adminsPage.setTag("Admins"); membersPage.setTag("Members"); outcastsPage.setTag("Outcast"); ownersList = (ListView) ownersPage.findViewById(R.id.list); adminsList = (ListView) adminsPage.findViewById(R.id.list); membersList = (ListView) membersPage.findViewById(R.id.list); outcastsList = (ListView) outcastsPage.findViewById(R.id.list); ownersList.setAdapter(new AffiliateAdapter(this)); adminsList.setAdapter(new AffiliateAdapter(this)); membersList.setAdapter(new AffiliateAdapter(this)); outcastsList.setAdapter(new AffiliateAdapter(this)); registerForContextMenu(ownersList); registerForContextMenu(adminsList); registerForContextMenu(membersList); registerForContextMenu(outcastsList); ArrayList<View> mPages = new ArrayList<View>(); mPages.add(ownersPage); mPages.add(adminsPage); mPages.add(membersPage); mPages.add(outcastsPage); MainPageAdapter adapter = new MainPageAdapter(mPages); ViewPager mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(adapter); mPager.setCurrentItem(0); TitlePageIndicator mTitleIndicator = (TitlePageIndicator) findViewById(R.id.indicator); mTitleIndicator.setTextColor(0xFF555555); mTitleIndicator.setViewPager(mPager); mTitleIndicator.setCurrentItem(0); }
From source file:com.notepadlite.NoteEditActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_note_edit); // Apply theme SharedPreferences pref = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE); String theme = pref.getString("theme", "light-sans"); LinearLayout noteViewEdit = (LinearLayout) findViewById(R.id.noteViewEdit); if (theme.contains("light")) noteViewEdit.setBackgroundColor(getResources().getColor(R.color.window_background)); if (theme.contains("dark")) noteViewEdit.setBackgroundColor(getResources().getColor(R.color.window_background_dark)); // Set action bar elevation if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getSupportActionBar().setElevation(getResources().getDimensionPixelSize(R.dimen.action_bar_elevation)); if (!(getSupportFragmentManager().findFragmentById(R.id.noteViewEdit) instanceof NoteEditFragment)) { // Handle intents Intent intent = getIntent();/*from w w w. ja v a 2 s . co m*/ String action = intent.getAction(); String type = intent.getType(); // Intent sent through an external application if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type)) { external = intent.getStringExtra(Intent.EXTRA_TEXT); Bundle bundle = new Bundle(); bundle.putString("filename", "new"); Fragment fragment = new NoteEditFragment(); fragment.setArguments(bundle); // Add NoteEditFragment getSupportFragmentManager().beginTransaction() .add(R.id.noteViewEdit, fragment, "NoteEditFragment").commit(); } else { showToast(R.string.loading_external_file); finish(); } // Intent sent through Google Now "note to self" } else if ("com.google.android.gm.action.AUTO_SEND".equals(action) && type != null) { if ("text/plain".equals(type)) { external = intent.getStringExtra(Intent.EXTRA_TEXT); if (external != null) { try { // Write note to disk FileOutputStream output = openFileOutput(String.valueOf(System.currentTimeMillis()), Context.MODE_PRIVATE); output.write(external.getBytes()); output.close(); // Show toast notification and finish showToast(R.string.note_saved); finish(); } catch (IOException e) { // Show error message as toast if file fails to save showToast(R.string.failed_to_save); finish(); } } } } else finish(); } }
From source file:ovh.ice.icecons.LicenseActivity.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()); int padding = Math.round(64 * 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 ww w . ja v 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); // gpl button LinearLayout sourceLayout = new LinearLayout(this); sourceLayout.setOrientation(LinearLayout.HORIZONTAL); sourceLayout.setLayoutParams(smallLayoutParams); sourceLayout.setGravity(Gravity.CENTER); 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) { gplLink(v); } }); TextView sourceText = new TextView(this); sourceText.setText("This program's source code is avaiable under the GNU General Public License v3."); sourceText.setTextSize(24); sourceText.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark)); sourceText.setPadding(padding, padding, padding, padding); sourceClickLayout.addView(sourceText); // cc button LinearLayout imgLayout = new LinearLayout(this); imgLayout.setOrientation(LinearLayout.HORIZONTAL); imgLayout.setLayoutParams(smallLayoutParams); imgLayout.setGravity(Gravity.CENTER); imgLayout.setBackgroundColor(0xff000000); baseLayout.addView(imgLayout); LinearLayout imgClickLayout = new LinearLayout(this); imgClickLayout.setOrientation(LinearLayout.HORIZONTAL); imgClickLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); imgClickLayout.setGravity(Gravity.CENTER); imgLayout.addView(imgClickLayout); imgClickLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ccLink(v); } }); TextView aboutText = new TextView(this); aboutText.setText( "All the images included in this program are avaiable under the Creative Commons Attribution Share Alike 4.0 license."); aboutText.setTextSize(24); aboutText.setTextColor(0xffffffff); aboutText.setPadding(padding, padding, padding, padding); imgClickLayout.addView(aboutText); }
From source file:net.ustyugov.jtalk.activity.note.NotesActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); service = JTalkService.getInstance(); setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark); setTitle(R.string.notes);// w ww .j a v a 2s .co m getActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.paged_activity); LinearLayout linear = (LinearLayout) findViewById(R.id.linear); linear.setBackgroundColor(Colors.BACKGROUND); LayoutInflater inflater = LayoutInflater.from(this); MainPageAdapter adapter = new MainPageAdapter(mPages); Cursor cursor = service.getContentResolver().query(JTalkProvider.ACCOUNT_URI, null, AccountDbHelper.ENABLED + " = '" + 1 + "'", null, null); if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst(); do { final String account = cursor.getString(cursor.getColumnIndex(AccountDbHelper.JID)).trim(); View templatePage = inflater.inflate(R.layout.list_activity, null); templatePage.setTag(account); mPages.add(templatePage); ListView list = (ListView) templatePage.findViewById(R.id.list); list.setDividerHeight(1); list.setCacheColorHint(0x00000000); list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) { final Note note = (Note) parent.getItemAtPosition(position); CharSequence[] items = new CharSequence[2]; items[0] = getString(R.string.Edit); items[1] = getString(R.string.Remove); AlertDialog.Builder builder = new AlertDialog.Builder(NotesActivity.this); builder.setTitle(R.string.Actions); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: createDialog(account, note); break; case 1: try { NoteManager nm = NoteManager.getNoteManager(service.getConnection(account)); nm.removeNote(note); updateNotes(); } catch (Exception ignored) { } break; } } }); builder.create().show(); return true; } }); } while (cursor.moveToNext()); cursor.close(); } mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(adapter); mPager.setCurrentItem(0); TitlePageIndicator mTitleIndicator = (TitlePageIndicator) findViewById(R.id.indicator); mTitleIndicator.setTextColor(0xFF555555); mTitleIndicator.setViewPager(mPager); }
From source file:com.anjalimacwan.activity.NoteEditActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_note_edit); // Apply theme SharedPreferences pref = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE); String theme = pref.getString("theme", "light-sans"); LinearLayout noteViewEdit = (LinearLayout) findViewById(R.id.noteViewEdit); if (theme.contains("light")) noteViewEdit.setBackgroundColor(ContextCompat.getColor(this, R.color.window_background)); if (theme.contains("dark")) noteViewEdit.setBackgroundColor(ContextCompat.getColor(this, R.color.window_background_dark)); // Set action bar elevation if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getSupportActionBar().setElevation(getResources().getDimensionPixelSize(R.dimen.action_bar_elevation)); if (!(getSupportFragmentManager().findFragmentById(R.id.noteViewEdit) instanceof NoteEditFragment)) { // Handle intents Intent intent = getIntent();//from w w w. j av a2s. c om String action = intent.getAction(); String type = intent.getType(); // Intent sent through an external application if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type)) { external = intent.getStringExtra(Intent.EXTRA_TEXT); if (external != null) { newNote(); } else { showToast(R.string.loading_external_file); finish(); } } else { showToast(R.string.loading_external_file); finish(); } // Intent sent through Google Now "note to self" } else if ("com.google.android.gm.action.AUTO_SEND".equals(action) && type != null) { if ("text/plain".equals(type)) { external = intent.getStringExtra(Intent.EXTRA_TEXT); if (external != null) { try { // Write note to disk FileOutputStream output = openFileOutput(String.valueOf(System.currentTimeMillis()), Context.MODE_PRIVATE); output.write(external.getBytes()); output.close(); // Show toast notification and finish showToast(R.string.note_saved); finish(); } catch (IOException e) { // Show error message as toast if file fails to save showToast(R.string.failed_to_save); finish(); } } } } else newNote(); } }
From source file:net.ustyugov.jtalk.activity.note.TemplatesActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); service = JTalkService.getInstance(); setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark); setTitle(R.string.Templates); getActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.paged_activity); LinearLayout linear = (LinearLayout) findViewById(R.id.linear); linear.setBackgroundColor(Colors.BACKGROUND); LayoutInflater inflater = LayoutInflater.from(this); MainPageAdapter adapter = new MainPageAdapter(mPages); Cursor cursor = service.getContentResolver().query(JTalkProvider.ACCOUNT_URI, null, AccountDbHelper.ENABLED + " = '" + 1 + "'", null, null); if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst();// w w w . j a va2 s. c o m do { final String account = cursor.getString(cursor.getColumnIndex(AccountDbHelper.JID)).trim(); View templatePage = inflater.inflate(R.layout.list_activity, null); templatePage.setTag(account); mPages.add(templatePage); ListView list = (ListView) templatePage.findViewById(R.id.list); list.setDividerHeight(0); list.setCacheColorHint(0x00000000); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { Note item = (Note) parent.getItemAtPosition(position); setResult(RESULT_OK, new Intent().putExtra("text", item.getText())); finish(); } }); list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) { final Note note = (Note) parent.getItemAtPosition(position); CharSequence[] items = new CharSequence[2]; items[0] = getString(R.string.Edit); items[1] = getString(R.string.Remove); AlertDialog.Builder builder = new AlertDialog.Builder(TemplatesActivity.this); builder.setTitle(R.string.Actions); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: createDialog(account, note); break; case 1: try { NoteManager nm = NoteManager.getNoteManager(service.getConnection(account)); nm.removeNote(note); updateNotes(); } catch (Exception ignored) { } break; } } }); builder.create().show(); return true; } }); } while (cursor.moveToNext()); cursor.close(); } mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(adapter); mPager.setCurrentItem(0); TitlePageIndicator mTitleIndicator = (TitlePageIndicator) findViewById(R.id.indicator); mTitleIndicator.setTextColor(0xFF555555); mTitleIndicator.setViewPager(mPager); }