Problem image: https://i.stack.imgur.com/0AUL9.png
I have a grid view, that has my HomeViewShortcutItemView
s.
In my HomeViewShortcutItemView
onMeasure, I'm making it square:
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width = getMeasuredWidth();
setMeasuredDimension(width, width); /* make grid item square */
}
And in my this view's xml, I'm setting height to match_parent:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/wrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/blue"
>
...
</RelativeLayout>
But it's rendering it's wrap_content
height in grid view item, because onMeasure do not effect it's child view, but making it square as I want.
How can I achive what I want?
By the way, here is the GridView Xml:
<pe.kor.browser.Ui.TabView.HomeView.StaticGridView
android:id="@+id/gridViewShortcuts"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false"
android:listSelector="@drawable/view_home_shortcut_item_bg"
android:stretchMode="columnWidth"
android:verticalSpacing="4dp"
android:horizontalSpacing="4dp"
/>