Why does my android emulator have different background than main.xml ? - java

So, I have a holo light theme, I am developing for android 3.0 and in my main.xml graphical layout shows a black screen which is what i want, but when I run the app on my android emulator version 3.0, it has a white background.
I want to have a black background, but main.xml layout shows me black background only the emulator shows different, why ????
Thanks, I have been developing for a week, but it's quite annoying. Thanks !!

The key is to customize Android Graphical XML Editor(Lets call it AGXE) properly to match the exact outcome of your program. For this purpose there are several ways of customizations are available.
In your case you are using Holo.Light the for your application, in your AGXE theme customization(in the light blue highlight) might be Holo/Theme.Holo (or something else) which has a black appearance for blank space.
If you want to know how your app layout will look in Holo.Light theme you have to manually set your theme to Holo.Light/Theme.Holo.Light
There are other controls in the AGXE, which can be used to get the most accurate representation of your layout in real life/emulator you specified (highlighted)(If you want explanations for each ask in comments below).
If you want to set a black background as Theme.Holo, you just have to put a single line code in all your layout android:background="#000000" which will set your entire background as black instead of white (even in Theme.Holo.Light), or you can specify your theme as Theme.Holo.
Read more here

Related

Different Themes in Android Studio

I am currently trying to create a settings menu for my app, where different theme colors (also gradients) can be chosen. When a color gets selected I want all parent layout backgrounds of activities and fragments to have this color. I thought about creating different styles in my theme.xml and based on the chosen color I apply that theme by using setTheme(...). But when I create a style in my theme.xml file by using <item name="android:background">#drawable/gradient</item> all backgrounds of the UI elements also have that background. Can someone tell me how I can create styles that only affect the parent layout background or suggest any other solution?

button background color is always purple in android studio

I am coding in android studio for some months and everything worked great. In the last 2 weeks I updated android studio and since then, every time I put a button its color is defined as purple no matter what I am doing, even if I change its background.
I tried to change it from the xml and also from the java file but without success.
If someone knows how to change it, it would be very helpful.
Thanks for answers.
the color of the button
Instead of button use <androidx.appcompat.widget.AppCompatButton>
Setting the app:backgroundTint to the color or transparent as well fixed this for me.
Change the theme.xml
style name="Theme.PROJECTNAME" parent="Theme.AppCompat.Light.NoActionBar">
Then the button without background will become grey and can be edited by color and drawable

What's the most efficient way to change the overall theme of the app?

So I got an idea for an app that would change visual theme based on user's selection, something like how a Sub-Reddit would have the option for users to switch between themes. In this case, I would utilize at least 4 themes, each theme changing the color of certain views, such as the background, buttons, image, and etc. I would like to know the the best approach to this. Do I need to keep a list of views that would be affected or something?
I've tried keeping different button backgrounds with different color since setting background color programmatically would reset the background shape back to the default design, but I'm afraid that it will cause the app to be bloated with numerous files. I've tried using the color filter to change the views.
Color id still keeps the filter applied to it, causing it be unusable if user switch to different color, then back.
Hopefully, this question was directed at native development. If so, then you should take a look at the guidelines. You can create your themes in XML and reference them in your layout XML files.
Personally, I would store the theme as a SharePreference somewhere and then when laying out each Activity/Fragment, utilize the user's saved theme.

Transparency in Background Picture

I want to achive that I have a transparent background BUT with a picture !
So if got this in the XML file of my layout :
android:background="#drawable/wallpaperpic"
Now I want to transparent it so the background menu (f.ex. widgets or app menu) is seeable but also my drawable/wallpaperpic and the rest of my buttons etc are normal (100%).Hopefully I was able to express my self !
My Background : https://amazingpict.com/wp-content/uploads/2015/04/polygon-texture.jpg
I want to have this
WHERE you also can see my background picture a bit
Try to set the alpha property of the view, like:
yourView.serAlpha(10);
If, as I'm guessing now, you have two layouts, one within the other, where the parent layout has the background, you can do this in the child layout:
android:background="#null"
This way, you can see the background, and your elements are intact.
Option 1 is to convert your image to a PNG and add an alpha channel.
Option 2 (which I would recommend) is to have a separate view that acts as your background, and set the alpha property for this view only. You can use a FrameLayout to put this background view underneath your other controls.
In my opinion use TintableBackgroundView.
TintableBackgroundView.
If you launch your activity the normal way, the system will not render anything behind it (i.e. the launcher will be completely gone - it could even remove it from memory).
You'll need to implement your activity as an alert window. This answer has details on how to implement it.

Android Dropdown Effect - Spinner or not?

Achieving a true "dropdown" effect (as seen in Adobe's Photoshop Mobile app for Android, image below) has proven challenging using Androids built-in methods.
As others on Stackoverflow have told me, editing the style of a dropdown list view of an Android spinner is limiting.
How is this dropdown effect done?
(I can't seem to get an image to show, so here's a link: Adobe Photoshop Mobile for Android
After viewing the Adobe slideshow I think the way I would attempt to get that to work, using the Android Java SDK, would be to create a ListView object with a transparent background, and then dynamically hide/show it in that position when the menu button is clicked by setting the View's visibility to VISIBLE or GONE.
Getting a ListView to be transparent shouldn't be that difficult. I'd look into AbsoluteLayout to get it to hover over everything in that spot.
Another option might be to display the ListView in a custom Dialog that you've written, again positioning it in that exact spot on the screen so that it looks like a menu extending from the button that was clicked.
It's probably done using low-level draw functions.

Categories

Resources