List of usage examples for android.view View setBackgroundColor
@RemotableViewMethod public void setBackgroundColor(@ColorInt int color)
From source file:com.hanbing.library.android.view.CustomTabLayout23.java
protected int getIndicatorLeft(View tabView, int position) { tabView.setBackgroundColor(Color.LTGRAY); ((ViewGroup) tabView).getChildAt(1).setBackgroundColor(Color.GRAY); return ((ViewGroup) tabView).getChildAt(1).getLeft() + tabView.getLeft(); }
From source file:com.aniruddhc.acemusic.player.PlaylistEditorActivity.PlaylistEditorArtistsMultiselectAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { final Cursor c = (Cursor) getItem(position); SongsListViewHolder holder = null;// w w w . j a va 2 s . co m if (convertView == null) { convertView = LayoutInflater.from(mContext).inflate(R.layout.music_library_editor_artists_layout, parent, false); holder = new SongsListViewHolder(); holder.image = (ImageView) convertView.findViewById(R.id.artistThumbnailMusicLibraryEditor); holder.title = (TextView) convertView.findViewById(R.id.artistNameMusicLibraryEditor); holder.checkBox = (CheckBox) convertView.findViewById(R.id.artistCheckboxMusicLibraryEditor); convertView.setTag(holder); } else { holder = (SongsListViewHolder) convertView.getTag(); } final View finalConvertView = convertView; final String songId = c.getString(c.getColumnIndex(DBAccessHelper._ID)); final String songArtist = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ARTIST)); String songAlbumArtPath = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM_ART_PATH)); holder.title.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); holder.title.setPaintFlags(holder.title.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); //Set the song title. holder.title.setText(songArtist); mApp.getImageLoader().displayImage(songAlbumArtPath, holder.image, PlaylistEditorActivity.displayImageOptions); //Check if the song's DB ID exists in the HashSet and set the appropriate checkbox status. if (PlaylistEditorActivity.songDBIdsList.contains(songId)) { holder.checkBox.setChecked(true); convertView.setBackgroundColor(0xCC0099CC); } else { holder.checkBox.setChecked(false); convertView.setBackgroundColor(0x00000000); } //Set a tag to the row that will attach the artist's name to it. convertView.setTag(R.string.artist, songArtist); holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton checkbox, boolean isChecked) { if (isChecked == true) { //Only receive inputs by the user and ignore any system-made changes to the checkbox state. if (checkbox.isPressed()) { finalConvertView.setBackgroundColor(0xCC0099CC); AsyncGetArtistSongIds task = new AsyncGetArtistSongIds(mContext, songArtist); task.execute(new String[] { "ADD" }); } } else if (isChecked == false) { //Only receive inputs by the user and ignore any system-made changes to the checkbox state. if (checkbox.isPressed()) { finalConvertView.setBackgroundColor(0x00000000); AsyncGetArtistSongIds task = new AsyncGetArtistSongIds(mContext, songArtist); task.execute(new String[] { "REMOVE" }); } } } }); return convertView; }
From source file:com.aniruddhc.acemusic.player.MusicLibraryEditorActivity.MusicLibraryEditorArtistsMultiselectAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { final Cursor c = (Cursor) getItem(position); SongsListViewHolder holder = null;/* www. ja v a 2s . co m*/ if (convertView == null) { convertView = LayoutInflater.from(mContext).inflate(R.layout.music_library_editor_artists_layout, parent, false); holder = new SongsListViewHolder(); holder.image = (ImageView) convertView.findViewById(R.id.artistThumbnailMusicLibraryEditor); holder.title = (TextView) convertView.findViewById(R.id.artistNameMusicLibraryEditor); holder.checkBox = (CheckBox) convertView.findViewById(R.id.artistCheckboxMusicLibraryEditor); convertView.setTag(holder); } else { holder = (SongsListViewHolder) convertView.getTag(); } final View finalConvertView = convertView; final String songId = c.getString(c.getColumnIndex(DBAccessHelper._ID)); final String songArtist = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ARTIST)); String songAlbumArtPath = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM_ART_PATH)); holder.title.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); holder.title.setPaintFlags(holder.title.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); //Set the song title. holder.title.setText(songArtist); mApp.getImageLoader().displayImage(songAlbumArtPath, holder.image, MusicLibraryEditorActivity.displayImageOptions); //Check if the song's DB ID exists in the HashSet and set the appropriate checkbox status. if (MusicLibraryEditorActivity.songDBIdsList.contains(songId)) { holder.checkBox.setChecked(true); convertView.setBackgroundColor(0xCC0099CC); } else { holder.checkBox.setChecked(false); convertView.setBackgroundColor(0x00000000); } //Set a tag to the row that will attach the artist's name to it. convertView.setTag(R.string.artist, songArtist); holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton checkbox, boolean isChecked) { if (isChecked == true) { //Only receive inputs by the user and ignore any system-made changes to the checkbox state. if (checkbox.isPressed()) { finalConvertView.setBackgroundColor(0xCC0099CC); AsyncGetArtistSongIds task = new AsyncGetArtistSongIds(songArtist); task.execute(new String[] { "ADD" }); } } else if (isChecked == false) { //Only receive inputs by the user and ignore any system-made changes to the checkbox state. if (checkbox.isPressed()) { finalConvertView.setBackgroundColor(0x00000000); AsyncGetArtistSongIds task = new AsyncGetArtistSongIds(songArtist); task.execute(new String[] { "REMOVE" }); } } } }); return convertView; }
From source file:knayi.delevadriver.AvaliableJobDetailActivity.java
private void setBackgroundAlpha(View view, float alpha, int baseColor) { int a = Math.min(255, Math.max(0, (int) (alpha * 255))) << 24; int rgb = 0x00ffffff & baseColor; view.setBackgroundColor(a + rgb); }
From source file:org.mixare.MixListView.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { itemPosition = position;/*from www .j a v a2 s . co m*/ if (convertView == null) { convertView = myInflater.inflate(R.layout.main, null); holder = new ViewHolder(); holder.text = (TextView) convertView.findViewById(R.id.list_text); holder.description = (TextView) convertView.findViewById(R.id.description_text); holder.checkbox = (CheckBox) convertView.findViewById(R.id.list_checkbox); holder.datasource_icon = (ImageView) convertView.findViewById(R.id.datasource_icon); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.datasource_icon.setImageResource(mixListView.getDataSourceIcon().get(position)); holder.checkbox.setChecked(mixListView.getDataSourceChecked().get(position)); holder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mixListView.clickOnDataSource(position); } }); holder.text.setPadding(20, 8, 0, 0); holder.description.setPadding(20, 40, 0, 0); holder.text.setText(mixListView.getDataSourceMenu().get(position)); holder.description.setText(mixListView.getDataSourceDescription().get(position)); int colorPos = position % bgcolors.length; convertView.setBackgroundColor(bgcolors[colorPos]); holder.text.setTextColor(textcolors[colorPos]); holder.description.setTextColor(descriptioncolors[colorPos]); return convertView; }
From source file:im.vector.adapters.VectorMediasViewerAdapter.java
@Override public Object instantiateItem(ViewGroup container, final int position) { View view = mLayoutInflater.inflate(R.layout.adapter_vector_medias_viewer, null, false); // hide the pie chart final PieFractionView pieFractionView = (PieFractionView) view.findViewById(R.id.media_slider_piechart); pieFractionView.setVisibility(View.GONE); final WebView imageWebView = (WebView) view.findViewById(R.id.media_slider_image_webview); final View videoLayout = view.findViewById(R.id.media_slider_videolayout); final ImageView thumbView = (ImageView) view.findViewById(R.id.media_slider_video_thumbnail); imageWebView.getSettings().setDisplayZoomControls(false); imageWebView.setOnLongClickListener(new View.OnLongClickListener() { @Override//from www .j av a 2s . co m public boolean onLongClick(View v) { VectorMediasViewerAdapter.this.onLongClick(); return true; } }); thumbView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { VectorMediasViewerAdapter.this.onLongClick(); return true; } }); // black background view.setBackgroundColor(0xFF000000); imageWebView.setBackgroundColor(0xFF000000); videoLayout.setBackgroundColor(0xFF000000); final SlidableMediaInfo mediaInfo = mMediasMessagesList.get(position); String mediaUrl = mediaInfo.mMediaUrl; if (mediaInfo.mMessageType.equals(Message.MSGTYPE_IMAGE)) { imageWebView.setVisibility(View.VISIBLE); imageWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); imageWebView.getSettings().setJavaScriptEnabled(true); imageWebView.getSettings().setLoadWithOverviewMode(true); imageWebView.getSettings().setUseWideViewPort(true); imageWebView.getSettings().setBuiltInZoomControls(true); videoLayout.setVisibility(View.GONE); final int rotationAngle = mediaInfo.mRotationAngle; final String mimeType = mediaInfo.mMimeType; File mediaFile = mMediasCache.mediaCacheFile(mediaUrl, mimeType); // is the high picture already downloaded ? if (null != mediaFile) { if (mHighResMediaIndex.indexOf(position) < 0) { mHighResMediaIndex.add(position); } } else { // try to retrieve the thumbnail mediaFile = mMediasCache.mediaCacheFile(mediaUrl, mMaxImageWidth, mMaxImageHeight, null); } // the thumbnail is not yet downloaded if (null == mediaFile) { // display nothing container.addView(view, 0); return view; } String mediaUri = "file://" + mediaFile.getPath(); String css = computeCss(mediaUri, mMaxImageWidth, mMaxImageHeight, rotationAngle); final String viewportContent = "width=640"; loadImage(imageWebView, Uri.parse(mediaUri), viewportContent, css); container.addView(view, 0); } else { loadVideo(position, view, mediaInfo.mThumbnailUrl, mediaUrl, mediaInfo.mMimeType); container.addView(view, 0); } // check if the media is downloading String downloadId = mMediasCache.downloadMedia(mContext, mSession.getHomeserverConfig(), mediaUrl, mediaInfo.mMimeType); if (null != downloadId) { pieFractionView.setVisibility(View.VISIBLE); pieFractionView.setFraction(mMediasCache.getProgressValueForDownloadId(downloadId)); pieFractionView.setTag(downloadId); mMediasCache.addDownloadListener(downloadId, new MXMediaDownloadListener() { @Override public void onDownloadError(String downloadId, JsonElement jsonElement) { pieFractionView.setVisibility(View.GONE); MatrixError error = JsonUtils.toMatrixError(jsonElement); if ((null != error) && error.isSupportedErrorCode()) { Toast.makeText(VectorMediasViewerAdapter.this.mContext, error.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } } @Override public void onDownloadProgress(String aDownloadId, DownloadStats stats) { if (aDownloadId.equals(pieFractionView.getTag())) { pieFractionView.setFraction(stats.mProgress); } } @Override public void onDownloadComplete(String aDownloadId) { if (aDownloadId.equals(pieFractionView.getTag())) { pieFractionView.setVisibility(View.GONE); } } }); } return view; }
From source file:im.neon.adapters.VectorMediasViewerAdapter.java
@Override public Object instantiateItem(ViewGroup container, final int position) { View view = mLayoutInflater.inflate(R.layout.adapter_vector_medias_viewer, null, false); // hide the pie chart final PieFractionView pieFractionView = (PieFractionView) view.findViewById(R.id.media_slider_piechart); pieFractionView.setVisibility(View.GONE); final WebView imageWebView = (WebView) view.findViewById(R.id.media_slider_image_webview); final View videoLayout = view.findViewById(R.id.media_slider_videolayout); final ImageView thumbView = (ImageView) view.findViewById(R.id.media_slider_video_thumbnail); imageWebView.getSettings().setDisplayZoomControls(false); imageWebView.setOnLongClickListener(new View.OnLongClickListener() { @Override//from w w w .j a v a2 s . c om public boolean onLongClick(View v) { VectorMediasViewerAdapter.this.onLongClick(); return true; } }); thumbView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { VectorMediasViewerAdapter.this.onLongClick(); return true; } }); // black background view.setBackgroundColor(0xFF000000); imageWebView.setBackgroundColor(0xFF000000); videoLayout.setBackgroundColor(0xFF000000); final SlidableMediaInfo mediaInfo = mMediasMessagesList.get(position); String mediaUrl = mediaInfo.mMediaUrl; if (mediaInfo.mMessageType.equals(Message.MSGTYPE_IMAGE)) { imageWebView.setVisibility(View.VISIBLE); imageWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); imageWebView.getSettings().setJavaScriptEnabled(true); imageWebView.getSettings().setLoadWithOverviewMode(true); imageWebView.getSettings().setUseWideViewPort(true); imageWebView.getSettings().setBuiltInZoomControls(true); videoLayout.setVisibility(View.GONE); final int rotationAngle = mediaInfo.mRotationAngle; if (TextUtils.isEmpty(mediaInfo.mMimeType)) { mediaInfo.mMimeType = "image/jpeg"; } final String mimeType = mediaInfo.mMimeType; File mediaFile = mMediasCache.mediaCacheFile(mediaUrl, mimeType); // is the high picture already downloaded ? if (null != mediaFile) { if (mHighResMediaIndex.indexOf(position) < 0) { mHighResMediaIndex.add(position); } } else { // try to retrieve the thumbnail mediaFile = mMediasCache.mediaCacheFile(mediaUrl, mMaxImageWidth, mMaxImageHeight, null); } // the thumbnail is not yet downloaded if (null == mediaFile) { // display nothing container.addView(view, 0); return view; } String mediaUri = "file://" + mediaFile.getPath(); String css = computeCss(mediaUri, mMaxImageWidth, mMaxImageHeight, rotationAngle); final String viewportContent = "width=640"; loadImage(imageWebView, Uri.parse(mediaUri), viewportContent, css); container.addView(view, 0); } else { loadVideo(position, view, mediaInfo.mThumbnailUrl, mediaUrl, mediaInfo.mMimeType); container.addView(view, 0); } // check if the media is downloading String downloadId = mMediasCache.downloadMedia(mContext, mSession.getHomeserverConfig(), mediaUrl, mediaInfo.mMimeType, mediaInfo.mEncryptedFileInfo); if (null != downloadId) { pieFractionView.setVisibility(View.VISIBLE); pieFractionView.setFraction(mMediasCache.getProgressValueForDownloadId(downloadId)); pieFractionView.setTag(downloadId); mMediasCache.addDownloadListener(downloadId, new MXMediaDownloadListener() { @Override public void onDownloadError(String downloadId, JsonElement jsonElement) { pieFractionView.setVisibility(View.GONE); MatrixError error = JsonUtils.toMatrixError(jsonElement); if ((null != error) && error.isSupportedErrorCode()) { Toast.makeText(VectorMediasViewerAdapter.this.mContext, error.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } } @Override public void onDownloadProgress(String aDownloadId, DownloadStats stats) { if (aDownloadId.equals(pieFractionView.getTag())) { pieFractionView.setFraction(stats.mProgress); } } @Override public void onDownloadComplete(String aDownloadId) { if (aDownloadId.equals(pieFractionView.getTag())) { pieFractionView.setVisibility(View.GONE); } } }); } return view; }
From source file:org.de.jmg.learn._MainActivity.java
void setTextColors() { libLearn.gStatus = "setTextColors"; if (_txtMeaning1 == null) return;//from w w w . ja v a 2s. co m _txtMeaning1.setTextColor(_main.Colors.get(ColorItems.meaning).ColorValue); _txtMeaning2.setTextColor(_main.Colors.get(ColorItems.meaning).ColorValue); _txtMeaning3.setTextColor(_main.Colors.get(ColorItems.meaning).ColorValue); _txtWord.setTextColor(_main.Colors.get(ColorItems.word).ColorValue); _txtKom.setTextColor(_main.Colors.get(ColorItems.comment).ColorValue); /* * _txtMeaning1.setBackgroundColor(_main.Colors.get(ColorItems.background). * ColorValue); * _txtMeaning2.setBackgroundColor(_main.Colors.get(ColorItems.background * ).ColorValue); * _txtMeaning3.setBackgroundColor(_main.Colors.get(ColorItems.background * ).ColorValue); * _txtWord.setBackgroundColor(_main.Colors.get(ColorItems.background * ).ColorValue); * _txtKom.setBackgroundColor(_main.Colors.get(ColorItems.background * ).ColorValue); */ View v = findViewById(R.id.layoutMain); if (v != null) v.setBackgroundColor(_main.Colors.get(ColorItems.background).ColorValue); }
From source file:net.czlee.debatekeeper.DebatingActivity.java
/** * Resets the background colour to the default. * This should be called whenever the background colour preference is changed, as <code>updateGui()</code> * doesn't automatically do this (for efficiency). You should call <code>updateGui()</code> as immediately as * practicable after calling this.//from www . jav a2 s .c o m */ private void resetBackgroundColoursToTransparent() { for (int i = 0; i < mViewPager.getChildCount(); i++) { View v = mViewPager.getChildAt(i); if (v.getId() == R.id.debateTimer_root) { v.setBackgroundColor(COLOUR_TRANSPARENT); View speechNameText = v.findViewById(R.id.debateTimer_speechNameText); View periodDescriptionText = v.findViewById(R.id.debateTimer_periodDescriptionText); speechNameText.setBackgroundColor(COLOUR_TRANSPARENT); periodDescriptionText.setBackgroundColor(COLOUR_TRANSPARENT); } } }
From source file:at.ac.tuwien.caa.docscan.ui.CameraActivity.java
/** * Called after configuration changes -> This includes also orientation change. By handling * orientation changes by ourselves, we can prevent a restart of the camera, which results in a * speedup.//from w w w.ja v a 2 s. c om * @param newConfig new configuration */ @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); mDrawerToggle.onConfigurationChanged(newConfig); // Tell the camera that the orientation changed, so it can adapt the preview orientation: if (mCameraPreview != null) mCameraPreview.displayRotated(); // Change the layout dynamically: Remove the current camera_controls_layout and add a new // one, which is appropriate for the orientation (portrait or landscape xml's). ViewGroup appRoot = (ViewGroup) findViewById(R.id.main_frame_layout); if (appRoot == null) return; View f = findViewById(R.id.camera_controls_layout); if (f == null) return; appRoot.removeView(f); getLayoutInflater().inflate(R.layout.camera_controls_layout, appRoot); View view = findViewById(R.id.camera_controls_layout); view.setBackgroundColor(getResources().getColor(R.color.control_background_color_transparent)); // Initialize the newly created buttons: initButtons(); }