首页  »   Android

android 开发中GridView中怎么添加一张图片

网友分享于:2013-12-16  浏览:351次
android 开发中GridView中如何添加一张图片
就像微信一样,在它的gridview里一直有一张“+”的图片,且随着图片的选取,它会一直往后退,直至选满9张图片,它就消失了,请问这是怎么实现的?求高手解答!

------解决方案--------------------
addview  最好是用HorizontalScrollView 里面含有一个线性布局,线性布局.addView(img)
------解决方案--------------------
我帮你做了个动态向GridView添加图片的APK  需要的话可以M我想怎么添加就怎么添加
------解决方案--------------------
xml配置如下:
<RelativeLayout
                    android:id="@+id/photo_post_select_grid_frame"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:layout_marginTop="10dp" >

                    <com.gf.component.widget.ExtendGridView
                        android:id="@+id/photo_post_select_grid"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:background="@drawable/gf_inputbox_upload_pic"
                        android:fadingEdge="none"
                        android:gravity="center"
                        android:horizontalSpacing="4dip"
                        android:listSelector="@color/transparent"
                        android:padding="10dip"
                        android:scrollbarStyle="insideOverlay"
                        android:scrollbarThumbVertical="@drawable/gf_scrollbar"
                        android:scrollingCache="false"
                        android:stretchMode="columnWidth"
                        android:verticalSpacing="4dip"
                        gf:stretchable="true" />
                </RelativeLayout>


其中ExtendGridView实现如下
public class ExtendGridView extends GridView {

    private int mHorizontalSpacing;
    private int mVerticalSpacing;
    private int mNumColumns;

    private boolean mStretchable;
    private boolean mPenetrateTouch;

    private int mScreenWidth, mScreenHeight;

    public ExtendGridView(Context context) {
        this(context, null);
上一页1/3下一页

相关解决方案

最新解决方案