Hello i have used a Relativelayout in android using XML but when i see image in graphical layout there is small margin left at bottom in different screensizes.How to remove that margin.I also used a ScrollView in layout.
I think you have to set bottom margin in negative
like
android:layout_marginBottom="-10dip"
Check whether you have used padding for your layout,
Better post your layout file and/or screenshot.
Related
Trying to do this android tutorial,
Drag a Plain Text (EditText) element from the Palette pane to the
bottom of the layout, and add constraints to the left side of the
layout, the bottom of the layout, and the left side of the Send
Button. Set its attributes in the Attributes pane as follows:
Attribute
Value
id
editText_main
Right margin
8
Left margin
8
Bottom margin
16
But I do not see a way to set the layout margin. When I select the editText_main and input 8dp into the layout_marginLeft, and press Enter or Tab, the number 8dp disappears. It was swallowed without a burp.
It was not obvious, but I right clicked and then selected the Constrain menu and added constraints. Then I went into Attributes and it allowed me to modify the current value.
It seems like a design bug.
I'd advise you not to use the drag pane only, Some features are much easier with the xml editor
Goto you xml file add margins like this.
<EditText
android:layout_marginBottom="16dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp" />
It is not a bug, a constraint layout child CANNOT have a child with margins because it has a set position (if you just drag and drop it from the palette), the position wont change no matter what, so adding margins is useless, when its constrained those margins become useful because lets say i constraint a button to the left but i don't want it completely to the left, so lets add a marginLeft of 8 dp, in that case it is relevant to have a margin thats why the editor wasn't letting you add them until you constrained it.
You can see this in the "Text" tab, the position is absolute, margins are useless when the position is absolute. So the editor prevents you from adding them.
Whenever you add a constraint to it the editor gets rid of the absolute position and lets you add margins.
Maybe your tutorial didn't specify what layout to use since it used to not be relevant until constraint layout was implemented.
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.
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?
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 ?
I want to make an about button in the top left. I tried:
android:layout_gravity:"top|left"
but it doesn't work , I searched and all what I found was using RelativeLayout and if I use that I'll have to make all my layout from beginning and it's not that good like the linear layout.
Couldn't post the code here. So this is my code on pastebin
http://pastebin.com/5EjgyB0K
Here you have given android:layout_gravity="center" to the Linear Layout so it is going to set gravity of the layout and as center and your About Button is child of layout its to going to set in center and you have given Margin_top also.Try to remove gravity amd Margin_top and you can see the result, the button will be top|left of the screen.