Im trying to set gravity="bottom" on a LinearLayout, so its children Views stack at the bottom.
The problem is that when I check it on Eclipse it seems fine, but when I run in on the AVD it doesn't work. It just works as if gravity was set to top.
Here is my code:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp" >
<com.pepotegames.spotthedifferences.SquareImageView
android:id="@+id/picture"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom"
android:weightSum="4" >
<ImageView
android:id="@+id/stars"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:src="@drawable/stars"
android:background="#55000000"
android:adjustViewBounds="true" />
</LinearLayout>
This is how it looks in Eclipse, and how it should work:
https://i.stack.imgur.com/9ojaM.png
EDIT: btw my SquareImageView its just an extended ImageView. The problem has nothing to do with it, I've already tested the same layout with a normal ImageView and its the same results.
In case you wanna check it, here it is:
public class SquareImageView extends ImageView {
public SquareImageView(Context context) {
super(context);
}
public SquareImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
}
}
I couldn't solve it that way, so this is what I ended up doing
I made a square root layout, then I used another custom view, an extended ImageView that gets resized to a quarter of its parent height