Android customize first child of grid view

删除回忆录丶 提交于 2019-12-13 05:06:13

问题


I want a grid view in which first child alone should be there in first row with different layout design and remaining childs can be similar in their designs. How can I achieve this? Please refer to the screen shot to get the idea.


回答1:


This isn't really possible but it is possible to fake it. The trick is to split the bitmap in half and show each half as separate images. See Bigger image for first item of the gridview android for more information.




回答2:


There is one nasty way to do it. Add an empty entry to the list at position 1 And then in getView:

if position is 0 set layout width of that item to be 2x normal width.

if position is 1 (or make some kind of flag for that item) inflate empty layout like

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="200dip"
    android:visibility="gone" />


来源:https://stackoverflow.com/questions/17237500/android-customize-first-child-of-grid-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!