PDA

View Full Version : اسکرول در صفحه



milad.programmer
سه شنبه 26 خرداد 1394, 20:51 عصر
سلام دوستان من تازه دارم برنامه نویسی اندروید رو یاد میگیرم و دارم یه برنامه مینویسم و میخاستم که تو اون صفحه 20 تا دکمه بزارم و حالا 20 تا تو صفحه جا نمیشه میخاستم که به صورت اسکرول دکمه ها رو نمایش بدم . میخاستم بدونم کدش چیه چطوری باید اینکار و بکنم؟
ممنون.

malloc
سه شنبه 26 خرداد 1394, 21:04 عصر
داداش منم مثل خودت تازه کارم اما تا اونجا که میدونم باید عین اون 20 تا رو بزاری داخل یه اسکرول ویو ...

milad.programmer
سه شنبه 26 خرداد 1394, 21:44 عصر
داداش منم مثل خودت تازه کارم اما تا اونجا که میدونم باید عین اون 20 تا رو بزاری داخل یه اسکرول ویو ...
خب همینو که میگی چجور باید بنویسم کدش چیه؟

hosseinaryai
سه شنبه 26 خرداد 1394, 22:18 عصر
اصلن احتیاج نداری کدی بنویسی .. برو تو قسمت دیزاین ، یه کنترل اسکول ویو بذار توی صفحه ، بعد هر کنترلی خواستی به هر تعدادی که خواستی بچین توش..

tux-world
سه شنبه 26 خرداد 1394, 22:22 عصر
نمونه

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">


<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/scrollView4">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>

</LinearLayout>
</ScrollView>
</LinearLayout>

tux-world
سه شنبه 26 خرداد 1394, 22:24 عصر
اصلن احتیاج نداری کدی بنویسی .. برو تو قسمت دیزاین ، یه کنترل اسکول ویو بذار توی صفحه ، بعد هر کنترلی خواستی به هر تعدادی که خواستی بچین توش..
اشتباه میکنید دوست عزیز. اسکرول ویو تنها یه child میتونه داشته باشه. نمونه گذاشتم ببینید.

milad.programmer
سه شنبه 26 خرداد 1394, 22:28 عصر
نمونه

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">


<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/scrollView4">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>

</LinearLayout>
</ScrollView>
</LinearLayout>
چرا از دو تا LinearLayout استفاده شده؟

hosseinaryai
سه شنبه 26 خرداد 1394, 22:39 عصر
اشتباه میکنید دوست عزیز. اسکرول ویو تنها یه child میتونه داشته باشه. نمونه گذاشتم ببینید.

اوکی درست میگی .. من رو حساب اکلیپس که خودش اتوماتیک یه LinearLayout به اسکرول اضافه می کنه گفتم ..

hosseinaryai
سه شنبه 26 خرداد 1394, 22:49 عصر
چرا از دو تا LinearLayout استفاده شده؟

دو تا LinearLayout اضافه نکرد .. LinearLayout اولی کلن بدنه ی اصلیه صفحست (که البته میشه حذف هم بشه .. حداقل توی اندرویداستودیو وقتی حذف می کنی صفحه به اندازه ی تعداد کنترلی که داری باز میشه و می تونی راحت مدیریتشون کنی)
و همونطور که گفته شد خود اسکرول ویو تنها یک فرزند می گیره ، برای همین توش یه LinearLayout دیگه گذاشته شده تا تعداد کنترلی که خواستی توش بذاری ..