android


Setting background image faded in background


I am trying to do a wiki like activity where there is a faded background image thats downloaded from a repo and fades in to the background behind a linear layout. There are three problems I am having.
XML:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/bg_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cropToPadding="true"
android:scaleType="centerCrop" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:textColor="#FFFFFF" >
<LinearLayout>Several layouts within here....</LinearLayout>
</LinearLayout>
</FrameLayout>
1) I can get the image to show, but some some elements within the LinearLayout are not transparent until I open another app, then go back to my app. I think there might be some weird view caching built into android thats causing things like linearlayouts to have a solid background.
2) I cannot get the image to be 'faded' in the background. I almost want to just darken the image so the text on top of it stands out more. Would this be opacity on the image?
3) The animation to fade in doesn't work. I am using an AsyncTask to call back to a listener to set the background. Here is the code I use in the activity, InfoActivity:
bg =(ImageView)findViewById(R.id.bg_image);
public void onBgImageResponse(Bitmap background) {
if(background != null) {
bg.setAlpha(50);
bg.setImageBitmap(background);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(InfoActivity.this, R.anim.fadein_bg);
bg.setBackgroundDrawable(new BitmapDrawable(this.getResources(), background));
bg.startAnimation(myFadeInAnimation);
}
}
In fadein_bg.xml I have:
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0"
android:toAlpha=".5"
android:interpolator="#android:anim/accelerate_interpolator"
android:duration="2000" android:repeatCount="infinite"/>
</set>
Any help is greatly appreciated. I will put a bounty out if needed.
This most likely isnt due to caching. I would check on if the image is actually being set properly. It sounds like your just not setting/refreshing your views properly.
You'll need to set the alpha on this image:
image.setAlpha(x); // x is the alpha you want
Remove 'bg.setImageBitmap(background);' and set the alpha last.
In your fadedin xml try removing the repeatCount and interpolator and see if that helps.

Related Links

how to change the color of the button in activity_main? [duplicate]
Problems with multi-dex
Coudnt retrieve the graphical layout
ProgressDialog won't dismiss if I switch to another application even if the IntentService has finished
GC_FOR_ALLOCs ruin my simple search process
Listview Custom Selector issue
Importing actionbarsherlock on Android Studio 0.8.9
Android ListView endless loop both directions
Android Close dataBase Failed
Can't display table in Android
How do I repackaged an AAR for Android gradle manifest merger?
How to pick a value from a TextView into a ListView
ViewPager not displaying correct Image
How to permanently disable Wi-Fi, Bluetooth and USB Mass Storage in Android
CheckBox status save to database Android
How to record audio with Google Glass?

Categories

HOME
api
design-patterns
paraview
linkedin
merge
telegram
github-for-windows
css3
flex
mysql-workbench
cq5
emscripten
tail
onclick
android-json
vert.x
title
bing-maps
teechart
pattern-matching
project-intu
line
esoteric-languages
symfony-2.8
atlassian-stash
job-scheduling
breadth-first-search
question2answer
systemtime
ios10.2
postscript
fractions
sinch
paperjs
anki
scatter3d
powershell-ise
mustache
hibernate-validator
r-grid
linkedhashmap
classcastexception
getpixel
hunspell
hibernate-search
xdocreport
connection-pool
node-mssql
verifiable-c
jvmti
doc
plaintext
android-checkbox
flask-login
stylecop
snapchat
puredata
builder
yii2-api
zenhub
page-replacement
stdmap
java-bytecode-asm
edit
avx
boo
sundials
libjpeg
java-websocket
mouseleave
choice
async.js
vulcanize
file-uri
x-tag
ellucian-scribe
invoke-sqlcmd
kendo-upload
phpgrid
state-restoration
decimalformat
extjs-grid
pax-exam
.bash-profile
sony-lifelog-api
google-refine
git-ftp
bufferedinputstream
kubuntu
entity-framework-4.3
fits
public-html
boost-program-options
mruby
browserify-shim
easyrtc
cbind
template-deduction
authlogic
decoupling
ecslidingviewcontroller
gwt-openlayers
http-patch
windows-phone-8-sdk
cocoalibspotify-2.0
printdialog
pagedown
wp7test
server-administration
curb
patricia-trie
os.system
fitbounds
cross-database
apache-commons-dbutils
automationelement
google-ajax-api
drawtobitmap
strsep
http-daemon
load-time
cruisecontrol.rb
strtod
skype4java
purepdf
escrow

Resources

Encrypt Message