کلیدستان

نسخه‌ی کامل: گرید ویو سفارشی(custom gridview)
شما در حال مشاهده نسخه آرشیو هستید. برای مشاهده نسخه کامل کلیک کنید.
سلام و خسته نباشید

من هرچی دنبال یک gridview سفارشی داخل اینترنت گشتم کد بدرد بخوری پییدا نکردم.

ساخت گرید ویو داخل سایت هست امامن میخوام ظاهر اون قشنگ باشه از style زیر تشکل شده باشه. ممکنه کسی کمک کنه و نمونه کد داشته باشه؟


درود
اولا که به جای gridView از recyclerView استفاده کنید که خیلی بهینه تر و سبک تر هست
یه مثال ساده :
 
کد پی‌اچ‌پی:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/cv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        app:cardBackgroundColor="@color/white"
        app:cardElevation="5dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginRight="10dp"
            android:orientation="vertical">


            <LinearLayout
                android:layout_marginTop="10dp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="right"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/title_titr"
                    android:layout_width="wrap_content"
                    android:layout_height="90dp"
                    android:gravity="center_vertical"
                    android:paddingRight="10dp"
                    android:text="تیتر خبر"
                    android:textColor="@color/lightBlack"
                    android:textSize="18dp"/>

                <ImageView
                    android:contentDescription="عکس خبر"
                    android:id="@+id/img_titr"
                    android:layout_width="110dp"
                    android:layout_height="90dp"
                    android:scaleType="centerCrop"/>

            </LinearLayout>

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_gravity="bottom"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="5dp"
                android:background="@color/colorAccent"/>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="35dp"
                android:gravity="left"
                android:orientation="horizontal"
                android:paddingBottom="8dp"
                android:paddingTop="8dp">

                <ImageView
                    android:id="@+id/bookmark_news"
                    android:layout_width="35dp"
                    android:layout_height="match_parent"/>

                <ImageView
                    android:id="@+id/share_news"
                    android:layout_width="35dp"
                    android:layout_height="match_parent"/>

                <ImageView
                    android:layout_width="35dp"
                    android:layout_height="match_parent"
                    android:scaleType="fitEnd"/>

                <TextView
                    android:id="@+id/view_news"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:gravity="center_vertical"
                    android:text="156165"/>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="right|center_vertical"
                    android:text="1394/5/8"/>
            </LinearLayout>

        </LinearLayout>
    </android.support.v7.widget.CardView> 




دوما خودتون باید آیتم های یک لیست رو طراحی کنید که بسیار ساده ست اما اگر میخواید از پروژه های آماده استفاده کنید بهتره سری به گیت هاب بزنید .
ممنون ومتشکر

پروژه های github با اندروید استودیو نوشته شده اونهایی که من دیدم
من میخواستم با ایکلیپس بنویسمشم

نمونه کد اگه دوستان دارن بفرستن ممنون میشم