【问题标题】:How to enable scrolling functionality to linear layout in android?如何在android中启用滚动功能到线性布局?
【发布时间】:2011-06-10 11:19:38
【问题描述】:

谁能帮助我如何启用线性布局的滚动功能?

【问题讨论】:

  • 删除了称呼:“提前感谢,\n Sathish。”,下次不要这样做

标签: android scroll android-linearlayout


【解决方案1】:

使用滚动视图?

<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">
    </ScrollView>
</LinearLayout>

【讨论】:

  • 如何在不使用线性布局内的滚动视图的情况下做到这一点?
  • 有什么理由不想要 ScrollView?
  • scrollview 是您正在寻找的。它只能包含一个子布局,如果需要,可以在其中一个 xml 属性中删除侧面的滚动条。
  • 我需要在不使用 Scrollview 的情况下使线性布局可滚动,因为我在线性布局内有一个网格视图,如果它在滚动视图内则无法正确滚动。有办法吗?
  • scollview 里面只能有一项
【解决方案2】:

您可以在滚动视图中放置任何内容以使某些内容(LinearLayout、RelativeLayout 等)可滚动。您可以关注http://www.androidpeople.com/android-scrollview-example了解更多详情。

【讨论】:

    【解决方案3】:

    将你的内容放在滚动视图中

      <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 ,为他提供宽度和长度,然后使用任何布局或视图并为其提供宽度和高度。

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2014-08-03
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多