I got my application uploaded and I see that despite I have the same background image on all my layouts.
if I switch, the layout moves according to the animation.
Is there a way for me to set a fixed background for all my layouts?
Does it matter that I finish(); every layout before I switch to the next one?
Setting the same background to all the layouts doesn't make it fixed (it moves)
neither does creating a style like :
<style name="AppTheme.FullBackground" parent="AppTheme">
<item name="android:background">#mipmap/background</item>
</style>
and adding :
android:theme="#style/AppTheme.FullBackground"
to the manifest.
Any ideas?
If you are using all activities in your app then change all activities to fragment and just use one activity with your required image as background.
Then use just this activity for all the fragments in your app. This will not move your background image during navigating to different screens(fragments)
Related
Recently I used this java code in Main_Activity:
(getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS))
for status Bar Transparent purpose. All went well, but my Android Navigation Bar also went to transparent policy.
Now I need only transparent my Status Bar, but not the Navigation Bar.
You have two options to do, first, one which I recommend for you would be using an external library for status-bar styling like StatusBarUtil library, which enables you to fulfill your requirement in just one line:
StatusBarUtil.setTransparent(Activity activity) // yo be placed in every activity you want the status bar to be transparent in
And this library doesn't affect the navigation bar.
Just make sure first to implement the library in your app level Gradle:
implementation'com.jaeger.statusbarutil:library:1.5.1'
Second option, is to go for layout customization, as mentioned in this tutorial, you can add the following to your style.xml:
<style name="AppTheme.TransparentTheme">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
And apply this style to the Activity in the manifest:
<activity
android:name=".HomeActivity"
android:theme="#style/AppTheme.TransparentTheme">
</activity>
As described in the tutorial:
I have set android:windowDrawsSystemBarBackgrounds to true.
This is a flag whose description is given below:
Flag indicating whether this Window is responsible for drawing the
background for the system bars. If true and the window is not
floating, the system bars are drawn with a transparent background and
the corresponding areas in this window are filled with the colors
specified in {#link android.R.attr#statusBarColor} and {#link
android.R.attr#navigationBarColor}. Corresponds to {#link
android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS}.
Don't forget to add the attribute android:fitsSystemWindows="true" to the top root of your activity layout.
I'm using this awesome library Dragger to add drag features to my activity, but is there a way to limit the width of the activity when it shows up or dragged..!? I don't want it to fill the entire screen..! kinda like the drawer navigation menu (see the pic below).
I was thinking of Dialog Activity, but it seems to be concerned with dialogs only and won't allow filling the other 3 sides or I not fully understand it..!
Any help?
Activity is not a view, so it does not have a size. Its' layout views do however.
You can try changing their sizes. Or, as it is an animation lib, you can try modifying existing or adding your own animations where views change sizes when moving. You can modify this param:
<item name="android:windowAnimationStyle">#null</item>
This might help you.
Everytime,I touch on a view or menu item, navigation item or anything on the screen, the screen turns black for a second(or less) and then opens another activity or Fragment. I have seen similar type of question(that is regarding scrolling a list), Does "cacheColorHint" attribute works here?
try adding this to your theme:
<item name="android:windowDisablePreview">true</item>
or , Try this in Manifest.. inside your activity
android:theme="#android:style/Theme.Translucent"
Or
android:theme="#android:style/Theme.Light"
I'm trying to figure out which is best to use.
I'm trying to develop a simple game and designing the starting activity. to start the game I plan to have a start button.
I want to use a custom design though.
My question is, should I use an ImageButton (which I believe is an imported image that you can click on, or a textview with android:background="#drawable/imageName".
Both seem to allow onClick if I'm not mistaken so what's the pros and or one over the other?
Hope this isn't duplicate question, all I found was info on how to upload images which I don't need. Just need to know advantages to using one versus the other.
also, Does onclick for textview apply to background or only text?
I think imagebutton maybe better.
because you must have a click effect for feedback . if you use background for the image ,you have to write a selector.xml for change the click and unclick effects.
so, i think imagebutton may be better.
You can use android:src="#drawable/imageName"
So that the image will be perfect fit. Also you can use
android:scaleType="fitCenter"
android:adjustViewBounds="true"
If you are using TextView then your background may not be good
From : Difference between a clickable ImageView and ImageButton
There's no differences, except default style. ImageButton has a non-null background by default.
Also, ImageButton.onSetAlpha() method always returns false, scaleType is set to center and it's always inflated as focusable.
Here's ImageButton's default style:
<style name="Widget.ImageButton">
<item name="android:focusable">true</item>
<item name="android:clickable">true</item>
<item name="android:scaleType">center</item>
<item name="android:background">#android:drawable/btn_default</item>
</style>
Currently I am trying to make an activity that can be moved on the screen , in other words this activity can float on the screen. I know I am missing something that should be added to achieve this functionality.
What should I do to achieve floating activity which can be moved around anywhere on the screen?
If you're looking to do something similar to the Facebook chat circles (where you have a view on top of other apps) then take a look here: http://www.cloudinfy.com/2013/06/android-chat-head-view-like-in-facebook.html
Basically you need to start a service and add a view to the window manager.
If you're looking to simply create an activity to look like a dialog then have a look here: Android Activity as a dialog
This is very similar to a normal activity but the theme is set to Theme.Dialog
There's a good solution here: http://cases.azoft.com/android-tutorial-floating-activity/
They just add an attribute to the theme of a tablet Activity:
<item name="android:windowIsTranslucent">true</item>
If any problems on KitKat devices, add some lines to the theme:
<item name="android:windowIsFloating">true</item>
<item name="android:windowCloseOnTouchOutside">false</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:backgroundDimEnabled">true</item>