Make last view fit to bottom of screen - android

is there any possibility to change the properties of the last view in the layout to change its size to fit to the bottom of the whole screen (in any screen density).
Here is a sample image of my layout:
The layout contains a ScrollView with a LinearLayout as only child. The last item in this LinearLayout is a TableView with a grey gradient as background.

You can try setting layout_height of your items to "fill_parent" and change their sizes via changing layout_weight property, that should work.

If you want the grey part to stick to the bottom you should put weight=1.0 and wrap content for height on the view that is above that one (the white area).

Checked it again on similar layout. The main work does the property android:fillViewport="true" Which
Defines whether the scrollview should stretch its content to fill the viewport
More infos: ScrollView.html#attr_android:fillViewport

Related

Android Dynamically changing one child Layout height

I wanted to make a layout which has three children layout.
the bottom layout must visible to bottom
screen size is enough:
the center layout need Dynamically change to wrap_content and we need the bottom layout is under the center layout (not top of the parent).
screen size is not enough:
fix size of center layout will fixed and it is a scrollview, it's height is dependency on the reminding width(if screen size is not enough)
I think a lot of ideas but i don't know how can do using xml. It can be only calculate in runtime?
this is the intend image:
you can use wrap_content in xml
OR
To change programatically you can use following code
Your_Layout.getLayoutParams().height = 100;

CardView vs LinearLayout - images scalling issue

Please look at following 2 layouts.
First, cardview:
http://pastebin.com/iYzUiDQ7
Second, LinearLayout only (layout is actually the same as the one inside my CardView):
http://pastebin.com/xijHZCPw
So, second layout contains WebView component + single LinearLayout under it that should represent the same layout as single CardView item.
It works, however... I'm having problems with scaling images. If I set very large image as image for my ImageView placed on CardView, it will be scaled nicely to fit on my CardView. CardView's height won't be changed, instead, image will be scaled proportionally to fit.
But when I'm trying to do the same with second layout I linked, my LinearLayout changes its height if I set large image. How should I change my second layout to get the same effect for my LinearLayout, placed at bottom of my screen?
I get the difference between the two layout.
you had set the layout_height with 100dp in CardView. so the height of LinearLayout in CardView will does not beyond that. But you set the layout_height with wrap_content in you second LinearLayout.
Try to set maxHeight or layout_height with digit to deal with you problem.
Hope this can help you.

relativelayout space between its elements when background image is present

I have a relative layout with background image (9patch). I have set this image as background to the layout using xml. When I add another relative layout which has buttons and textviews, there is little space left before the new layout. I didnt set any padding. I also tried by setting padding top to 0. If i remove the background image the alignment will be proper with no space left on top of new layout. I have also tried by setting match parent and fill parent in new layout but still the space remains on top of it. The space left is very little like 3dp-5dp.
can someone suggest about this issue pls.
EDIT : space is on top of the new layout horizontally and i have tried setting gravity to top and also top left.
The black pixels on the top and left define the stretch area of the 9-patch, while the pixels on the bottom and right define the fill area. My guess is that you have a fill area defined that does not cover the entire right and bottom edges.
Here's a good guide.

android app - make view only take up portion of parent view

I have a background image on my app, and I want my listview to be in the form of a window that overlays the background image. Sort of like the the form which has a white filter in this picture:
http://25.media.tumblr.com/ad75c4a9dad9650ed53d754712f4fbb2/tumblr_mgemxiU2W01r2wjwko2_1280.png
I currently have a listview defined in xml with:
android:layout_width="fill_parent"
android:layout_height="fill_parent"
and a semi transparent color as its background. This is great, but it takes up the whole screen, since it fills the parent width and height. What is the best way to make it slightly smaller than the parent's dimensions so that it is say, (fill_parent - some relative value) height and width?
Use margin in a layout to make it smaller relative to the parent layout and other child's
Use a FrameLayout as a parent, then add your ListView and set width and height to wrap_content. Now it should "float" above the other views inside the FrameLayout. You can use padding and margin to set its position.

Android - How to place an item on a layout relatively to the top?

How could I proceed to place an item on a LinearLayout, with a given space from the top? For instance, I would like to place the logo on the half of the top middle of the layout.
Thanks
There is no way to add percentages.
You can add two layouts with the same weight to split the screen in two and then add the logo with a centered gravity to the upper layout,
Or you can measure the screen and add the right amount of margins.
Use the paddingTop attribute of the view class.

Categories

Resources