0
I wanted to change the background color of an activity, I’ve seen some topics here but without success. When selecting in the spinner the activity color will be changed to black, or white. How do I change colors?
0
I wanted to change the background color of an activity, I’ve seen some topics here but without success. When selecting in the spinner the activity color will be changed to black, or white. How do I change colors?
0
or using rgb colors in Linearlayout
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
**android:background="#ffffff"**>
0
You can do it that way
Add an id to your view and then take the view in your Activity and set the color
To create blocks of code, you can use the button {}
above the edit box.
vlw, I didn’t know that
Perfect! How to animate the change? I saw a topic on the Transictiondrawable, however I could not, if I can complement your answer how to animate, I thank you very much
I tried to put this: Transitiondrawable Transition = (Transitiondrawable) view.getBackground(); Transition.startTransition(1000); however from this error: E/Androidruntime(1689): FATAL EXCEPTION: main 09-18 22:39:48.560: E/Androidruntime(1689): Process: with.example.exercicio, PID: 1689 09-18 22:39:48.560: E/Androidruntime(1689): java.lang.Classcastexception: android.graphics.drawable.Colordrawable cannot be cast to android.graphics.drawable.Transitiondrawable
Browser other questions tagged android
You are not signed in. Login or sign up in order to post.
this question has been answered in the Soen http://stackoverflow.com/questions/20032594/android-need-to-change-the-spinner-background-color
– Thallyson Dias
@Thallyson, it’s not the same thing. EN OS’s question changes the Spinner background, not Activity’s.
– Wakim
Yes, I don’t want to change the spinner, but the background of the activity
– War Lock
I tried to put Linearlayout li=(Linearlayout)findViewById(R.layout.activity_main); li.setBackgroundColor(Color.RED); li.invalidate(); But unsuccessfully hangs, and the nullPointException
– War Lock
If the swap is static (a fixed number only), you can create a Theme that extends the application theme, where only the attribute varies
android:background
, according to the choice (SharedPreferences
p.e). I usually use the theme solution because I offer only two pro user themes in the app settings. How does it giveNPE
? theli
is null? Include the error code and thestacktrace
if you can.– Wakim