Подтвердить что ты не робот

Как включить функцию прокрутки для линейной компоновки в android?

Может ли кто-нибудь помочь мне, как включить функцию прокрутки для linearlayout?

4b9b3361

Ответ 1

Использовать ScrollView?

<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="110px">

Ответ 2

Вы можете поместить что-нибудь внутри прокрутки, чтобы сделать что-то (LinearLayout, RelativeLayout и т.д.) прокручиваемым. Вы можете следить за http://www.androidpeople.com/android-scrollview-example для получения более подробной информации.

Ответ 3

Поместите содержимое внутри scrollview

  <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:id="@+id/ScrollViewID"
    android:layout_width="fill_parent"
    android:layout_height="match_parent">
     <!-- your content --->
  </ScrollView>
  </LinearLayout>

Ответ 4

Оберните свой контент внутри ScrollView

Ответ 5

scrollview может содержать только один элемент. поэтому для обеспечения вашей функциональности вам необходимо установить линейную компоновку (как правило..) и добавлять пользовательские представления или макеты в качестве дочернего элемента в линейный макет.

Я советую вам использовать listview и ArrayLists для создания прокручиваемого списка

Ответ 6

вид прокрутки займет только один прямой дочерний элемент под ним. Вы можете использовать этот код в качестве образца. Надеюсь, это поможет вам.

                              

<TableLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">

<TableLayout android:id="@+id/syncservice_url" android:layout_width="wrap_content" android:layout_height="match_parent" >
   <TextView android:text="Settings" android:textColor="@color/Black" android:textSize="6pt" android:typeface="serif"/>
<View android:background="@color/Black" android:layout_height="1dip" android:layout_marginBottom="5dip"/>

        <TextView android:text="Multimedia file list Url" android:textColor="@color/Black" android:textSize="5pt" android:typeface="serif" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
    <EditText android:layout_width="match_parent" android:id="@+id/multimediafileListUrl"  android:layout_height="40dip"></EditText>



        <TextView android:text="Multimedia Download Url" android:textColor="@color/Black" android:textSize="5pt" android:typeface="serif" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
    <EditText android:layout_width="match_parent" android:id="@+id/MultiMediaDownloadUrl"  android:layout_height="40dip"></EditText>



        <TextView android:text="Reports Upload Url" android:textColor="@color/Black" android:textSize="5pt" android:typeface="serif" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
    <EditText android:layout_width="match_parent" android:id="@+id/ReportUploadUrl"  android:layout_height="40dip"></EditText>



        <TextView android:text="Presentation Timimg Url" android:textColor="@color/Black" android:textSize="5pt" android:typeface="serif" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
    <EditText android:layout_width="match_parent" android:id="@+id/PresentationTimeUrl"  android:layout_height="40dip"></EditText>


</TableLayout><!-- sync scrvice closed -->

   <TableLayout android:id="@+id/report_url" android:layout_width="wrap_content" android:layout_height="match_parent" >

    <TextView android:text="Reporting " android:textColor="@color/Black" android:textSize="6pt" android:typeface="serif"/>
    <View android:background="@color/Black" android:layout_height="1dip" android:layout_marginBottom="5dip"/>


        <TextView android:text="Report Submit Url" android:textColor="@color/Black" android:textSize="5pt" android:typeface="serif" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
    <EditText android:layout_width="match_parent" android:id="@+id/ReportSubmitUrl"  android:layout_height="40dip"></EditText>



        <TextView android:text="Appointment List Url" android:textColor="@color/Black" android:textSize="5pt" android:typeface="serif" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>

<EditText android:gravity="left" android:maxLines="1"
                    android:layout_marginRight="10dip" 
                    android:cursorVisible="false" android:layout_width="match_parent"
                    android:layout_height="40dip" android:id="@+id/AppointMentListUrl" />

  </TableLayout><!-- sync Report closed -->
   <TableLayout android:id="@+id/Locationmap_url" android:layout_width="wrap_content" android:layout_height="match_parent" >


        <TextView android:text="IMEI Post Url" android:textColor="@color/Black" android:textSize="5pt" android:typeface="serif" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
    <EditText android:layout_width="match_parent" android:id="@+id/IMeiPostUrl" android:layout_height="wrap_content"></EditText>



        <TextView android:text="Kml Download Url" android:textColor="@color/Black" android:textSize="5pt" android:typeface="serif" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
    <EditText android:layout_width="match_parent" android:id="@+id/kmldownloadurl"  android:layout_height="wrap_content"></EditText>

    <Button android:text="Save" android:id="@+id/SettingSave" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>     
</TableLayout><!--Locationmap closed -->

</TableLayout><!-- main table layout -->
 </TableLayout><!-- main table layout -->

</ScrollView>

Ответ 7

используйте ScrollView, укажите его ширину и длину, затем используйте любой макет или представление и укажите им их ширину и высоту.