Scrollview stretches background Android - 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

Related

Organise views/buttons after changing the font (setting->display->fontsize)

The layout has just two buttons in a linear layout and it looks like the following when the font size is default (setting->display->fontsize).
Now if I change the font to bigger size, it becomes to
But I would like to show the following
I wrote a custom linearlayout and tried to manipulate the layout's parameters based on the linecount in onLayout function. Most of the time it works well. However if the layout is part of nestedscrollview, it starts flickering.
Any suggestion or help would be appreciated. Thanks

Change the opacity/transparency of a view and affect the child views too

I have a relative layout with child TextViews.
The background of the parent RelativeLayout is white and I was wondering how I could change the alpha to change the opacity of the whole view programmatically (including children).
I am trying:
getBackground().setAlpha(0.4);
But that expects an int and not a float.
If I do:
getBackground().setAlpha((int)(0.4 * 255));
The latter changes the view but makes it darker than I want. Also the children do not seem to change. It seems to affect only the background while I want something that makes everything more "grayed" out/less transparent.
What am I doing wrong?
Have you tried using android:background="#88000000" in layout file. You can change alpha and color values as required.
That's because you are changing the backgound of the layout and not the layout itself. So instead of myRelativeLayout.getBackground().setAlpha(), use this: myRelativeLayout.setAlpha(0.4f).

Android Seekbar can't remove padding/background

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! :)

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.

How to resize the RelativeLayout or any other Layout in Android?

I have a RelativeLayout defined in xml and I call the setContentView(R.layout.relativeLAyout) for displaying in Activity.
Now, if I want to resize this RelativeLayout then can it be done and if yes, then can someone let me know how?
The inner components can be resized relatively to the parent.
Is this actually possible?
Regards
Sunil
well if you use Eclipse, in the XML file, there at the bottom just switch to Graphical Layout.
and from there you can drag and drop payouts, Buttons etc :D
then in properties you can select add the pixels (200px ) on width/height
As to the inner components not resizing, make sure that both android:layout_width and and android:layout_height are set to fill_parent - then they should take up the space given to the parent.

Categories

Resources