ورود

View Full Version : سوال: قرار دادن دو گریدویو در یک ویو



omid.n1990
پنج شنبه 06 شهریور 1393, 13:04 عصر
سلام، میخوام دوتا گرید ویو رو داخل یک ویو قرار بدم.
وقتی این دوتا رو داخل یک ویو قرار میدم یک مشکل پیش میاد. مشکلم تو تعیین ارتفاع گرید ویوهاست.
اگر layout_height رو برابر با wrap_content قرار بدم، هر کدروم گرید ویوها فقط ردیف اول رو به صورت پیش فرض نشون میده و واسه ردیفهای بعدی هر گرید ویو باید اسکرول خود اون گرید ویو رو انجام داد.
من میخوام محتوای هر گریدویو کامل نشون داده بشه (تمام آیتمهای هرگرید ویو کامل مشخص باشه) و با اسکرول خود ویوی اصلی بتونم بیام پایین و باقی آیتم ها و گرید ویو دوم رو ببینم.
اگر layout_height را برابر با مقداری مثل 800dp قرار بدم، مشخصا این اتفاق میفته و تمام آیتمهای گرید ویو کامل نشون داده میشه ولی خوب از قبل مشخص نیست چند آیتم توی گرید ویو میره و با توجه به سایز صفحه نمایش و تعداد آیتم ها و ... نمیتونم مقدار فیکس بدم.
کسی از دوستان میدونه باید چیکار کنم؟؟

esmail3309
پنج شنبه 06 شهریور 1393, 13:21 عصر
دوست عزیز من از این روش استفاده کردم
امتهان کنید:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_5"
tools:context=".MainActivity_gridview" >


<ScrollView
android:id="@+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >




<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/gridView3"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:src="@drawable/title_1" />
<GridView
android:id="@+id/gridView"
android:layout_width="wrap_content"
android:layout_height="600dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageView2"
android:layout_margin="4dp"
android:columnWidth="150dp"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" >
</GridView>


<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/gridView2"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:src="@drawable/title_3_1" />
<GridView
android:id="@+id/gridView2"
android:layout_width="wrap_content"
android:layout_height="1165dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageView2"
android:layout_margin="4dp"
android:columnWidth="150dp"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" >
</GridView>


<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/gridView2"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:src="@drawable/title_6" />
<GridView
android:id="@+id/gridView3"
android:layout_width="wrap_content"
android:layout_height="1165dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageView2"
android:layout_margin="4dp"
android:columnWidth="150dp"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" >
</GridView>

<ImageView
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/gridView2"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:src="@drawable/title_4" />
<GridView
android:id="@+id/gridView4"
android:layout_width="wrap_content"
android:layout_height="180dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageView2"
android:layout_margin="4dp"
android:columnWidth="150dp"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" >
</GridView>


<ImageView
android:id="@+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/gridView2"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:src="@drawable/title_5" />
<GridView
android:id="@+id/gridView5"
android:layout_width="wrap_content"
android:layout_height="600dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageView2"
android:layout_margin="4dp"
android:columnWidth="150dp"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" >
</GridView>


<ImageView
android:id="@+id/imageView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/gridView2"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:src="@drawable/title_2" />
<GridView
android:id="@+id/gridView6"
android:layout_width="wrap_content"
android:layout_height="800dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageView2"
android:layout_margin="4dp"
android:columnWidth="150dp"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" >
</GridView>



</LinearLayout>
</ScrollView>

</RelativeLayout>



البته تصاویر حذف کن
اگه درست نشد خبر بده

omid.n1990
پنج شنبه 06 شهریور 1393, 14:20 عصر
سلام دوست عزیز، بله کد شما رو دیده بودم. یعنی یکی دو روز سوالی پرسیده بودید که من جواب دادم:) در مورد تعداد caseها:) الان خودم نیاز پیدا کردم همچین چیزی
ولی مشکل اینه که شما هم ارتفاع رو ثابت در نظر گرفتید:
android:layout_height="600dp"
الان شما تو این کد سه تا اسکرول دارید! یک اسکرول کل صفحه و واسه هر گرید ویو هم یک اسکرول دیگه! که اینکار اصلا قشنگ نیست. اگر آیتم هاتون ثابت باشه شاید این مشکل رو متوجه نشدید و اگر تو گوشیهای دیگه تست کنید هم ممکنه مشکل بخوره.
من میخوام اسکرول گریدویوها رو غیرفعال کنم و اسکرول صفحه اصلی تنها اسکرول باشه. الان که توضیح دادم به نظرم بهتر میدونم میخوام چیکار کنم:) اگر به نتیجه رسید کارم بهتون اطلاع میدم
ممنون