I got BottomNavigationActivity and fragment in it. My fragment seems like it has margin on it, but it doesn't. If I stretch it - top part disappears.
How can I solve it?
That's because your ConstraintLayout has a android:paddingTop . Remove that I can't see it being necessary?
Also your fragment should have:
android:layout_width="match_parent"
android:layout_height="match_parent"
But because of your constraints I don't think the layout_width and layout_height is respected, might even be able to be 0dp you would need to test if that works for you
You are using a ConstraintLayout as Parent. There is top padding in your layout. remove the padding line from ConstraintLayout.
You set a custom height and width for the Fragment. Replace the custom size with match_parent. That will solve your problem. You can also use 0dp instead of match_parent. 0dp will automatically resize your fragment window according to the screen size.
Related
I have just started work with Android Studio 2.2.3. I picked TableLayout and everything looks fine, but I cant drag and drop anything on this layout except TableRow. Even the grid doesn`t show up. Has anybody had the same issue?
I am not clear what exactly you want to implement, if you want to implement grid view then instead of taking table layout take recycler view and implement it as a grid view. to know more about thie follow this link http://www.android-examples.com/android-recyclerview-with-gridview-gridlayoutmanager/
I think you are TableLayout as root layout with these properties: android:layout_width="match_parent"
android:layout_height="match_parent"
So it will occupies you entire Activity. It allows only TableRow because it is child layout for TableLayout.
Try to change the properties as following or change the TableLayout from Root layout and later add the views to layout.
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Updated to Android Support Library rev 23.2 and it added full screen spaces to RecyclerView between each item. Has anybody experienced this issue?
This occurs when your RecyclerView rows have their size set to match_parent in the scrolling direction.
For example, if a RecyclerView with a vertical LinearLayoutManager has the following layout for each row, that row will now actually match the parent's height now. Before version 23.2.0 it would still simply wrap the content.
<View
android:layout_width="match_parent"
android:layout_height="match_parent" />
In this case, changing the height to wrap_content will resolve the issue.
This issue is mentioned briefly in the announcement blog post:
Due to this change, make sure to double check the layout parameters of
your item views: previously ignored layout parameters (such as
MATCH_PARENT in the scroll direction) will now be fully respected.
What I am trying to achieve is to implement a typical texting screen, where I have a LinearLayout initially occupying the whole screen by setting the height to be fill_parent, except a RelativeLayout containing an EditText at the bottom of the screen using android:layout_alignParentBottom.
Now, I need to display an extra RelativeLayout at the bottom of the small RelativeLayout, which should reduce the height of the LinearLayout, and push the original RelativeLayout up.
Please advise what is the best way to achieve the above scenario. Thank you.
I find easier the use of RelativeLayout for cases like this.
You can define a RelativeLayout as a container of all of them and
place the others inside it.
Set your LinearLayout height to "match_parent"
Place the EditText below the LinearLayout; and the RelativeLayout,
below the EditText; using android:layout_below
Good luck friend!
I have the following layout:
<LinearLayout width:fill height:fill >
<RelativeLayout width:fill height:wrap >
<ImageView width:fill height:wrap >
<LinearLayout width:wrap height:wrap />
</RelativeLayout>
</LinearLayout>
The innermost LinearLayout seems to have no idea that it is inside the RelativeLayout when it comes to vertical properties. Gravity works only horizontally. For all intents and purposes (vertically), the inner LinearLayout thinks that the outer LinearLayout is its parent. Aligning parent Top/Bottom stretches it and the RelativeLayout to fill the outer LinearLayout.
Ultimately what I want here is for the relative layout height to wrap the imageview almost as if it was its background (though it's meant to be an overlay on top of another view on top of the background), and the linear layout to simply work inside the constraints of the relative layout.
Furthermore, I want to be able to clip anything that goes outside the bounds of the relative layout wrapping the imageview. What's my best option here?
I think your issue here is that wrap_content does not bound the upper limit of the View (at least by the parent). As such, the height of your RelativeLayout can go on to the full size of it's parent. If it's parent wasn't wrap_content too, it would stretch out to it's parent and so forth until it reaches a parent that has an upper-bound.
In this case, your top parent is bound by the size of the phone, so it stops there. Instead of using gravity on your inner-most LinearLayout. Use the attribute layout_centerInParent="true" on your inner-most LinearLayout. Unless the layout becomes bigger than your ImageView it should conform to the center of your RelativeLayout.
EDIT:
You may also want to experiment with the different Scale Types of the ImageView. There are some that will scale the image as big as it can get without cropping or distorting the ratio. There are some that will always fill the entire view but may crop or distort the image.
There are a lot of things that are unclear from your post, probably you should post the complete version of your XML code.
From my understanding, I guess you're not using RelativeLayout constraints such as layout_alignParentBottom="true" or layout_centerVertical="true". Those will work, unlike the gravity properties.
I am adding layouts programmatically.I have added a scrollview as a parent layout and a combination of horizontal and vertical linearlayouts when I add a list view in the scrollview I am getting an issue that my UI is not taking full screen although the listview height is set to fill parent .There is a blank space added at the bottom and the height of the listview gets very small .I haven't find the reason why it's happening, is it a bug in android for scrollview ?
fill_parent won't work. Try setting android:fillViewport="true".
Without any code, I'd have to take a guess and say that your ScrollView is not set to fill_parent.
Try using layout editor in Eclipse or the hierachyviewer that ships with the Android SDK to examine your layout in the emulator and see which view is not filling the screen.