I am learning GridView. As you can see from the screenshot below, I have added 13 buttons with various length strings as their text. However long text buttons overlap each other, I tried but I couldn't fix it. All I want is that each row has the same height of the most high element, for instance all the buttons in row 1 should have the "lorem ipsum dolor sit amet" s height, and all the other rows should have their longest elements height. How can I achieve this?
If it is not possible, alternatively I can have the following: All the elements are in their size, however the grid is not actually a rectangle, it can have the following scheme: (where there is actually no grid, it just appends the Views together in columns, without considering where is the acutal grid.
------------------------------------------------|
| | 2 | |
| 1 |---------------- 3 |
| | |----------------|
---------------| 5 | |
| 4 | | 6 |
|------------------------------|-----------------
My Gridview:
<GridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="90dp"
android:gravity="fill_vertical"
android:numColumns="3"
>
</GridView>
getView method of my adapter class that extens BaseAdapter:
public View getView(int position, View convertView, ViewGroup arg2) {
Button btn = null;
if (convertView == null) {
btn = new Button(mContext);
} else {
btn = (Button) convertView;
}
btn.setText(txts[position]);
return btn;
}
Note: I will have my custom view, I am just testing it with simple buttons.