Android Seekbar can't remove padding/background - android

What I want to achieve is something like this, a seekbar without any top and bottom padding:
What I get is this:
I tried even setting the background to transparent and then null but the background of the seekbar becomes white, it doesn't look like in the first image, I want the seekbar to look like it's placed between the both layouts (the upper layout is darker, and the layout from the bottom is lighter as you see in both photos). I'm using the basic attributes for the seekbar in xml, thanks!
EDIT:
This is the seekBar in XML.
I don't believe that it has something to do with the root layout, because everywhere if I'm starting a new project and I'm adding a seekbar it still has that background, and if I try to set it to transparent it becomes white.
<SeekBar
android:id="#+id/window_song_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/primaryColor"
android:paddingLeft="0px"
android:paddingRight="0px" />

Set following attributes in xml.
'android:paddingStart="0dp"
android:paddingEnd="0dp"'

SOLVED, bad layout positioning. I was using a LinearLayout as the root element with a vertical orientation, the seekbar was at the middle of two relative layouts, I used android:background="#color/myColor" for the root layout, then setting the background to transparent to the seekbar and now I got the desired effect. And also I changed the root layout from linear layout to a relative layout. Thank you! :)

Related

Android - Fading Layout Border

I am working on an android app and I have a scrollview, and in that, I have a linear layout in the main activity. I want to have the top and bottom borders of the linear layout to be "faded
" so as the user scrolls down the child views in the layout will "fade out" as the go down.
Here is an example of what I am trying to achieve in my linearlayout or scrollview (the "fading bottom border".
Thanks for you help!
Subby
You can do that by using the following attributes in the ScrollView.
android:requiresFadingEdge="vertical"
android:fadingEdgeLength="20dp"
If you want it on devices before API14, you need to use the following:
android:requiresFadingEdge="vertical"
android:fadingEdgeLength="20dp"
NOTE: This is actually discouraged as it is seen to have a negative performance impact on devices.
At the bottom of your layout, you can have a view above the listView, and set Gradient Color for the view, and also make it semitransparent, then you can have the effect you want.

Leave blank line in Linear Layout

I am developing for android. The app is designed in XML in Linear Layout. What I want to do is to leave some blank lines between the consecutive buttons/text to ensure some neatness in the GUI. Is it posible to do it in Linear Layout? Please help...
You should use margins to seperate different components in your layout. An example of how this would look in your XML is: android:layout_marginTop="12dp"
If you want to leave space outside the border of text/button and next view elements you can use android:layout_marginLeft, android:layout_marginRight, android:layout_marginTop and android:layout_marginBottom.
If you want to leave space between border of the text/button and actual content of the text/button you can use android:paddingLeft, android:paddingRight, android:paddingTop and android:paddingBottom.
For more info check out this question
how to increase the space between the elements in linearlayout in android?

Scrollview stretches background Android

I have read many question on this topic but found no answer.
the problem is that I have a ScrollView as mainView in my xml and if I set a background it is stretched.
ScrollView(background)-->content
I also tried:
Scrollview-->content(background)
To solve the issue I need to wrap the scrollView inside a LinearLayout.
LinearLayout(background)-->ScrolView-->content
Now the background (if applied to the mainLinearLayout) is no more stretched but I have the warning:
This ScrollView layout or its LinearLayout parent is possibly useless; transfer the background attribute to the other
view
I'd like to have the background not stretched and also get rid of this warning.
Probably I've not fully understood how this Views work...
Thanks for your help
Not a beautiful answer. But it should work.
You can set the background activity in styles xml file.
Remove useless LinearLayout.
Set the background of scrollview to transparent.
in your first case, use android:layout_height="wrap_content" for the scrollview and it won't stretch the background picture anymore

Bottom margin Android LinearLayout item in XML ignored, but works in Java code

I am developing an app with an activity with member reactions on a hike event. The reactions are the yellow "balloons" which are made using a LinearLayout. Each item is constructed from a XML file (listitem_deelnemerreactie.xml) which defines the layout for a reaction item. The top level of this layout file is a LinearLayout my itself.
I want some spacing between the separate elements, as well as some right margin. The most straightforward way to so this should be: setting a bottom and right margin on the top-level LinearLAyout element of the listitem_deelnemerreactie.xml layout file.
But setting the bottom margin on the LinearLayout has no effect on the vertical spacing, though the right margin does have an effect.
The only way to be able to set a vertical margin appears to be: setting is in the Java code, after attaching the inflated view to the container.
See the two images for the effect and the code.
Though setting the margins in the code is a working workaround, I still think it is strange this cannot be achieved in the XML. Why is the bottom margin attribute ignored while the right margin is not?
Any ideas?
Have you tried to set an android:padding="10dp" for example on your elements to spaced them ?

Android seekbar not showing

Folks, I have the following layout: http://dpaste.com/hold/755261/
It has two seekbar widgets. Both are not showing. If I move them to the root linearlayout, they appear, otherwise not. I need them to be inside the first linearlayout. Anyone could help me how to achieve that?
It looks like you need to put the following in your third LinearLayout:
android:layout_weight="1"
Change the second LinearLayout height to wrap_content. If the content doesn't fit on the screen, then maybe you have to use a ScrollView.

Categories

Resources