I have a simple LinearLayout in Android with two images vertically:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.eataly.android"
android:orientation="vertical"
android:background="@android:color/white"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/img_header1"
/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/img_header2"
/>
</LinearLayout>
As you can see at the following link, I can't get rid of a a gap at the top and at the bottom of the images: http://img185.imageshack.us/img185/8484/senzanomev.png
I've tried everything imaginable on the LinearLayout and the ImageViews, i.e.:
android:padding="0px"
android:top="0px"
android:bottom="0px"
android:top="0px"
android:layout_margin="0px"
with no success. What can I do to remove these empty borders?
RelativeLayout is a view group that displays child views in relative positions. The position of each view can be specified as relative to sibling elements (such as to the left-of or below another view) or in positions relative to the parent RelativeLayout area (such as aligned to the bottom, left or center).
android:orientation Use "horizontal" for a row, "vertical" for a column. The default is horizontal.
Advantages of using ConstraintLayout in AndroidIt helps to improve the UI performance over other layouts. With the help of ConstraintLayout, we can control the group of widgets through a single line of code. With the help of ConstraintLayout, we can easily add animations to the UI components which we used in our app.
Layout Weight This attribute assigns an "importance" value to a view in terms of how much space it should occupy on the screen. A larger weight value allows it to expand to fill any remaining space in the parent view.
I found the solution. I needed to add this attribute to the ImageView
:
android:adjustViewBounds="true"
add android:scaleType="fitXY" in xml layout.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With