I would like to have a bottom aligned button which has text positioned above safe area in a way that allows me to fill that space with the color of button and, ideally, is clickable too.
I was thinking about adding a Container with Gesture Detector there but can't figure out how to do it in a way that won't ruin layout on phones without safe area. That's how huge it looks when wrapped in SafeArea. Ideally there would be little to no margin above text in this button, something like this.
You can use flutter_screenutil instead of SafeArea, knowing the bottom and top safearea height by these 2 functions:
ScreenUtil.bottomBarHeight //Bottom safe zone distance, suitable for buttons with full screen
ScreenUtil.statusBarHeight //Status bar height , Notch will be higher Unit px
you can then control the height of safearea yourself
Related
I have Delphi FMX Android TFramedVerScrollBox with:
Margins.Right:=20;
ShowScrollbars:=True;
TouchTargeExpansion.Right:=80;
Width:=800;
which has a set of TLayout components as a set of children with individual settings for each TLayout:
Align:=Top;
Anchors:=[akLeft, akTop, akRight]
Size.Wdith:=800; //But I guess this is irrelevant, as Size should be determined automatically for children with Align:=Top
My question is - how can I set properties in a way, that:
TLayout children components give some space in their correct size for scrollbars to become visible? If TLayout.Padding.Right:=0, then TLayout children sit solidly in the place where the vertical scrollbar should be. If TLayout.Padding.Right:=50, then the entire children are moved to the left side - this is really strange. If width is computed automatically for the Align:=Tope children, then this Width should take into account the Padding of the children automatically and accordingly become smaller, less comprehensive.
Even I move the children to the left side and the scrollbar becomes visible - it is very, very narrow, just some 5-10 pixels. How can I increase the width of the scrollbar of TFramedVerScrollBox?
First :
"Padding" adds space to the inner side of the control (between the control borders and its children), while "Margins" adds space to the outer side of the control (to the borders of its Parent or between the control borders and another control within the same Parent).
So when you need to set distance between a TLayout and its "Parent" border (Right border of the TFramedVertScrollBox) then you must go either for Padding in the TFramedVertScrollBox or for Margins in its children controls.
But it is not necessary to set space for scrollbars. Because when a scrollbox (in Delphi apps like in anywhere else) is resized and its children are not completely visible, the scrollbox client area is resized automatically for letting space for showing scrollbars. And even if you set "Margins" for children controls, the scrollbox client area is resized and the children margins are moved. So you will get more margins that will ruin your UI design.
That size adaptation is common on Windows where the scrollbars are always completely shown with their classical aspect. While on Android, scrollbars are not explicitly shown, you may only see their "thumbs" when you try to drag on the side having the scrollbar.
Second :
The width of the scrollbar in TFramedVertScrollBox, like all layout controls, is defined by the style. You have to customize the style or create your own style where you can set the size and even the position of the scrollbar.
I am new to Android and recently I came up with a term 'match constraint' while using ConstraintLayout.
As per doc it says 'Dimension will be controlled by constraints', I don't understand what exactly mean by this ?
As far as I could understand , it's somehow can be used as replacement of match-parent but not sure how ?
First of all, lets look at what the word Constrain means. According to Google, Constrain means to
Compel or force to follow a particular course of action
Severely restrict the scope, activity or extent of
Bring about by compulsion
When using ConstraintLayout we align/position our items by applying Constraints to that particular item. What these Constraints do is that they limit (or allow) the position of that item in the screen. Lets say I have a button which I constrain to be between the left and right edge of the screen. By doing so, the button can move anywhere in the screen as long as it is within the left and right edges of the screen. Similar is the case if I constrain the button to be between the top and bottom of the screen.
Now what does MATCH_CONSTRAINT mean? It means, that the view will take up as much space as the Constraints allow it to take. So, if I constrain a view to be between the left and right edge of the screen, then the view will expand its width to be equal to the width of the screen (if no margins are set).
It means it will take the available space in the main constraint layout. For more details, you can read it from here
Is it possible to move a button or any other element in relative layout to the absolute edge of the sreen? If I drag a certain element to the edge of the layout, eclipse will automatically place it a few dp away from the edge. It'll basically just create a small space between a button and the end of the creen. Is it possible to bypass that?
I know buttons aren't meant to be that close to the edge of the screen anyway, but I need it for a certain thing.
The normal button has a little padding by default, because the buttons backgroundimage is a 9-patch image with padding left, right and on bottom. That's why you see the space between button and screen.
To solve this you can use a custom button. For example change the backgroundimage of button like this android:background="#drawable/image".
I have a problem with a specific layout in Android.
What I want to achieve is approximately this:
http://imgur.com/xiN0u
The green area should always be visible at the bottom of the screen (size can change, but only marginally)
The red area should fill the rest of the screen on top.
The cyan area (inside the red layout) is a ScrollView and can change size and should not grow bigger than the space available
What happens is this: when the list expands, depending on the layout (i have tried linear, relative, mix of those,...), either the red or green area is overlapped with the other and is not accessible any more:
http://imgur.com/b7leA
I have tried this for a day now and whatever I do, some part of the layout is always overlapped. Is there a way to tell a ScrollView to only expand to a certain height? I know maxHeight doesn't exist. I highly appreciate every input as this is driving me crazy now! Is this possible at all with Android?
I have a few issues and questions regarding some UI development on Android. Firstly look at this image:
Firstly at image A) This is a image that I insert and repeat horizontally to give the zig-zag shape at the top of the screen regardless of screensize and above that a textField with no content and a background color - But as I'm sure you can is that the two colors don't match up quite as perfectly as it should even though they both have the same hex color value (#BF0426). And secondly, you can also see some serious pixelation on that zig-zag image. How do I fix these 2 problems?
And then at image B) Here I have a simple listView. What I would like to do, is firstly indent it a bit on both sides, and round the corners of the top and bottom item. So basically I want it to look like the blue border drawn on the screenshot. (Your typical iOS listView). How do I go about doing this?
Thanks in advance for any tips!
For the image. Just out of curiosity, why wouldnt you simply extend your image to include the top pixels as well? In other words, build your repeating image such that it incorporates the pixels that you are trying to create using the empty textview. This will at least take care of the color missmatch, as the color will all be generated from the same place. In terms of the pixelation. Are you truly repeating the image, or are you spreading the image. A spreading will definitely cause what you are seeing.
For your tableview:
For the left and right indent, you can simply use the margin or padding attributes of tableview item. There are generic padding and/or margin attributes (which will pad all of the top, bottom, left and right), or there are separate padding and/or margin attributes for each top, bottom, left, and right. Here is a great link on padding versus margin that you may want to read.
Difference between a View's Padding and Margin
Example attribute (as called in an XML file) for bottom margin
android:layout_marginBottom
setMargins(left, top, right, bottom) // for setting margins programmatically
Example attribute (as called in an XML file) for top padding
android:paddingTop
setPadding(left, top, right, bottom) // for setting padding programmatically
For the custom top and bottom, you should be able to use the following tutorial
http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/
From here, you should be able to detect the item as the first and last item and set the background property (image) to a background image that has a rounded top or rounded bottom. This is how I do it on the iPhone. I have also implemented things that LOOK like tableviews but are simply vertical layouts with my own custom views that I have made to look like what you are wanting.
One thing to consider is the file format you use is going to mutate the image as you save it (lossy compression), so a .jpg with a certain color may look different than a .bmp with the same color. Make sure you author using the same application and/or export settings when trying to match up images.
Also, if you created your image with a DPI that is not compatible with the android display it can cause serious pixelation in detail areas, especially with gradients and drop shadows.