内的EditText启用滚动这是一个滚动型 [英] Enable Scrolling within EditText that is in a ScrollView

查看:314
本文介绍了内的EditText启用滚动这是一个滚动型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的应用程序(Android设备 字preSS)使用滚动视图为新的职位来看,其中一个用户进入其新的博客文章。有一个关于这个观点相当多的领域,其中包括大量的EditText为文章内容领域。

看来,当一个EditText处于滚动型,滚动型的接管滚动操作,因此用户不能滚动中的 的该区域的EditText如果他们写了大量文章。有什么可以做,这样的滚动会的EditText和滚动型?

内工作都

下面是这个观点的布局XML,任何帮助将是AP preciated!需要滚动的EditText上是@ ID /内容:

 <?XML版本=1.0编码=UTF-8&GT?;
<滚动型的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@ + ID /主
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:滚动条=无
    机器人:背景=#FFF5F5F5>< RelativeLayout的机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_gravity =CENTER_HORIZONTAL
                机器人:填充=10dip
                >
    < RelativeLayout的机器人:layout_width =FILL_PARENT
                机器人:layout_height =FILL_PARENT
                机器人:背景=@绘制/ content_bg
                机器人:ID =@ + ID / SECTION1>
    < TextView的机器人:ID =@ + ID / l_section1
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=后内容
              风格=@风格/字pressSectionHeader/>
    < TextView的机器人:ID =@ + ID / l_title
              机器人:layout_below =@ ID / l_section1
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=@字符串/ POST_TITLE/>    < EditText上机器人:ID =@ + ID /标题
              安卓了minHeight =40dip
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:背景=@机器人:可绘制/ editbox_background
              机器人:自动图文集=真
              机器人:利用=句子
              机器人:layout_below =@ ID / l_title/>    < TextView的机器人:ID =@ + ID / l_content
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=@字符串/ POST_CONTENT
              机器人:layout_below =@ ID /标题/>    < EditText上机器人:ID =@ + ID /内容
              机器人:重力=顶
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:背景=@机器人:可绘制/ editbox_background
              安卓的minlines =5
              机器人:MAXLINES =5
              机器人:自动图文集=真
              机器人:利用=句子
              机器人:layout_below =@ ID / l_content/><按钮
            机器人:ID =@ + ID /大胆
            机器人:背景=@绘制/ wp_button_small
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_below =@ ID /内容
            机器人:文字样式=大胆
            机器人:TEXTSIZE =22dip
            机器人:文字=B/>
<按钮
            机器人:ID =@ + ID / EM
            机器人:背景=@绘制/ wp_button_small
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_alignTop =@ ID /大胆
            机器人:layout_toRightOf =@ ID /大胆
            机器人:TEXTSTYLE =斜体
            机器人:TEXTSIZE =22dip
            机器人:文字=我/><按钮
             机器人:ID =@ + ID /链接
             机器人:背景=@绘制/ wp_button_small
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_alignTop =@ ID / EM
            机器人:layout_toRightOf =@ ID / EM
            机器人:TEXTSIZE =22dip
            机器人:文字颜色=#006699
            机器人:文字=链接/><按钮
            机器人:ID =@ + ID / bquote
            机器人:背景=@绘制/ wp_button_small
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_alignTop =@ ID /链接
            机器人:layout_toRightOf =@ ID /链接
            机器人:TEXTSIZE =22dip
            机器人:文字=B-引用/>
              < / RelativeLayout的>
< RelativeLayout的机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:背景=@绘制/ content_bg
                机器人:ID =@ + ID /第2节
                机器人:layout_marginTop =10dip
                机器人:layout_below =@ ID / SECTION1>
    < TextView的机器人:ID =@ + ID / l_media
              机器人:layout_marginBottom =6DIP
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=媒体
              风格=@风格/字pressSectionHeader/>
<按钮
            机器人:ID =@ + ID / addPictureButton
            机器人:layout_marginTop =4dip
            机器人:背景=@绘制/ wp_button_small
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_below =@ ID / l_media
            机器人:TEXTSIZE =18dip
            机器人:文字=@字符串/添加/><按钮
            机器人:ID =@ + ID / clearPicture
            机器人:背景=@绘制/ wp_button_small
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:知名度=水涨船高
            机器人:TEXTSIZE =18dip
            机器人:layout_alignBottom =@ ID / addPictureButton
            机器人:layout_toRightOf =@ ID / addPictureButton
            机器人:文字=@字符串/清除/>            < GridView控件
                    机器人:ID =@ + ID / GridView控件
                    机器人:layout_width =WRAP_CONTENT
                    机器人:layout_height =FILL_PARENT
                    机器人:重力=fill_vertical
                    机器人:为numColumns =3
                    机器人:知名度=水涨船高
                    机器人:layout_below =@ ID / addPictureButton>
               < / GridView的>
< / RelativeLayout的>
< RelativeLayout的机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:背景=@绘制/ content_bg
                机器人:ID =@ + ID / SECTION3
                机器人:layout_marginTop =10dip
                机器人:layout_marginBottom =10dip
                机器人:layout_below =@ ID /第2节>
                < TextView的机器人:ID =@ + ID / l_tags_categories
              机器人:layout_marginBottom =6DIP
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=标签&放大器;放大器;类别
              风格=@风格/字pressSectionHeader/>
                   < TextView的机器人:ID =@ + ID / l_tags
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:layout_below =@ ID / l_tags_categories
              机器人:文字=@字符串/ tags_separate_with_commas/>    < EditText上机器人:ID =@ + ID /标签
              安卓了minHeight =40dip
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:背景=@机器人:可绘制/ editbox_background
              机器人:自动图文集=真
              机器人:layout_below =@ ID / l_tags/>    < TextView的机器人:ID =@ + ID / l_category
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=@字符串/类别
              机器人:layout_below =@ ID /标签
              机器人:layout_marginTop =10dip/>  <按钮
            机器人:ID =@ + ID / selectCategories
            机器人:背景=@绘制/ wp_button_small
            机器人:layout_below =@ ID / l_category
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:TEXTSIZE =18dip
            机器人:文字=@字符串/ select_categories/>     < TextView的机器人:ID =@ + ID / selectedCategories
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=@字符串/ selected_categories
              机器人:layout_below =@ ID / selectCategories/>
 < / RelativeLayout的>
  < RelativeLayout的机器人:ID =@ + ID / location_wrapper
               机器人:layout_width =FILL_PARENT
               机器人:layout_height =WRAP_CONTENT
                机器人:layout_below =@ ID / SECTION3
                机器人:layout_marginTop = - 10dip>
  < RelativeLayout的机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:背景=@绘制/ content_bg
                机器人:ID =@ + ID / section4
                机器人:layout_marginTop =10dip
                机器人:layout_marginBottom =10dip
                机器人:layout_below =@ ID / SECTION3
                机器人:知名度=水涨船高>
                < TextView的机器人:ID =@ + ID / l_location
              机器人:layout_marginBottom =6DIP
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=@字符串/位置
              风格=@风格/字pressSectionHeader/>
              < TextView的机器人:ID =@ + ID / locationText
              机器人:layout_marginBottom =6DIP
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=@字符串/加载
              机器人:layout_below =@ ID / l_location/>
              <按钮
            机器人:ID =@ + ID /视图地图
            机器人:背景=@绘制/ wp_button_small
            机器人:layout_below =@ ID / locationText
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:TEXTSIZE =18dip
            机器人:文字=查看地图/>
 < / RelativeLayout的>
 < / RelativeLayout的>
 < RelativeLayout的机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:背景=@绘制/ content_bg
                机器人:ID =@ + ID / section5
                机器人:layout_marginTop =10dip
                机器人:layout_marginBottom =10dip
                机器人:layout_below =@ ID / location_wrapper>
                < TextView的机器人:ID =@ + ID / l_status
              机器人:layout_marginBottom =6DIP
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=@字符串/状态
              风格=@风格/字pressSectionHeader/>
    <复选框机器人:ID =@ + ID /出版的
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_below =@ ID / l_status
            机器人:文字=@字符串/出版的
            机器人:按钮=@绘制/ wp_checkbox
            />
 < / RelativeLayout的>
<按钮
            机器人:ID =@ + ID /后
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_below =@ ID / section5
            机器人:layout_alignParentRight =真
            机器人:TEXTSIZE =18dip
            机器人:背景=@绘制/ wp_button
            机器人:文字=@字符串/保存/>
<按钮
            机器人:ID =@ + ID /上传
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_alignBottom =@ ID /后
            机器人:layout_toLeftOf =@ ID /后
            机器人:TEXTSIZE =18dip
            机器人:背景=@绘制/ wp_button
            机器人:文字=@字符串/ upload_now/>
< / RelativeLayout的>
< /滚动型>


解决方案

从我读过一个论坛上,到目前为止,同一个屏幕上有几个滚动的容器是不是一个好主意。现在,这些岗位通常是有关的ListView,GridView控件与滚动型组合,但仍对我来说似乎是最好的解决办法重新设计的屏幕,以避免这种情况。

Our app (WordPress for Android) uses a scrollview for the new post view, where a user enters in their new blog post. There's quite a few fields on this view, including a large EditText for the post content field.

It appears that when an EditText is in a ScrollView, the ScrollView takes over the scrolling action, so the user can't scroll within the EditText area if they are writing a large post. What can be done so that scrolling will work both within the EditText and the ScrollView?

Here is the layout xml for this view, any help would be appreciated! The EditText that needs the scrolling is @id/content:

    <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/main"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scrollbars="none"
    android:background="#FFF5F5F5">

<RelativeLayout android:layout_width="fill_parent" 
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:padding="10dip"
                > 
    <RelativeLayout android:layout_width="fill_parent" 
                android:layout_height="fill_parent"
                android:background="@drawable/content_bg"
                android:id="@+id/section1">
    <TextView android:id="@+id/l_section1" 
              android:layout_width="fill_parent" 
              android:layout_height="wrap_content"
              android:text="Post Content"
              style="@style/WordPressSectionHeader"/>
    <TextView android:id="@+id/l_title" 
              android:layout_below="@id/l_section1"
              android:layout_width="fill_parent" 
              android:layout_height="wrap_content" 
              android:text="@string/post_title"/>

    <EditText android:id="@+id/title" 
              android:minHeight="40dip"
              android:layout_width="fill_parent" 
              android:layout_height="wrap_content" 
              android:background="@android:drawable/editbox_background"
              android:autoText="true"
              android:capitalize="sentences"
              android:layout_below="@id/l_title"/>

    <TextView android:id="@+id/l_content" 
              android:layout_width="fill_parent" 
              android:layout_height="wrap_content" 
              android:text="@string/post_content"
              android:layout_below="@id/title"/>

    <EditText android:id="@+id/content"
              android:gravity="top" 
              android:layout_width="fill_parent" 
              android:layout_height="wrap_content" 
              android:background="@android:drawable/editbox_background"
              android:minLines="5"
              android:maxLines="5"
              android:autoText="true"
              android:capitalize="sentences"
              android:layout_below="@id/l_content"/>

<Button  
            android:id="@+id/bold"
            android:background="@drawable/wp_button_small"
            android:layout_width="wrap_content"  
            android:layout_height="wrap_content"
            android:layout_below="@id/content"
            android:textStyle="bold"
            android:textSize="22dip"
            android:text="B" />           
<Button
            android:id="@+id/em"
            android:background="@drawable/wp_button_small"
            android:layout_width="wrap_content"  
            android:layout_height="wrap_content"
            android:layout_alignTop="@id/bold"
            android:layout_toRightOf="@id/bold"
            android:textStyle="italic"
            android:textSize="22dip"
            android:text="I " />

<Button
             android:id="@+id/link" 
             android:background="@drawable/wp_button_small"
            android:layout_width="wrap_content"  
            android:layout_height="wrap_content"
            android:layout_alignTop="@id/em"
            android:layout_toRightOf="@id/em"
            android:textSize="22dip"
            android:textColor="#006699"
            android:text="link" />  

<Button
            android:id="@+id/bquote"
            android:background="@drawable/wp_button_small"
            android:layout_width="wrap_content"  
            android:layout_height="wrap_content" 
            android:layout_alignTop="@id/link"
            android:layout_toRightOf="@id/link"
            android:textSize="22dip"
            android:text="b-quote" />          
              </RelativeLayout>
<RelativeLayout android:layout_width="fill_parent" 
                android:layout_height="wrap_content"
                android:background="@drawable/content_bg"
                android:id="@+id/section2"
                android:layout_marginTop="10dip"
                android:layout_below="@id/section1">             
    <TextView android:id="@+id/l_media"
              android:layout_marginBottom="6dip"
              android:layout_width="fill_parent" 
              android:layout_height="wrap_content"
              android:text="Media"
              style="@style/WordPressSectionHeader"/>               
<Button
            android:id="@+id/addPictureButton"
            android:layout_marginTop="4dip"
            android:background="@drawable/wp_button_small"
            android:layout_width="wrap_content"  
            android:layout_height="wrap_content"
            android:layout_below="@id/l_media" 
            android:textSize="18dip"
            android:text="@string/add"/>

<Button
            android:id="@+id/clearPicture"
            android:background="@drawable/wp_button_small"
            android:layout_width="wrap_content"  
            android:layout_height="wrap_content" 
            android:visibility="gone"
            android:textSize="18dip"
            android:layout_alignBottom="@id/addPictureButton"
            android:layout_toRightOf="@id/addPictureButton"
            android:text="@string/clear" />

            <GridView   
                    android:id="@+id/gridView"   
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="fill_vertical"
                    android:numColumns="3"
                    android:visibility="gone"
                    android:layout_below="@id/addPictureButton">             
               </GridView>
</RelativeLayout>
<RelativeLayout android:layout_width="fill_parent" 
                android:layout_height="wrap_content"
                android:background="@drawable/content_bg"
                android:id="@+id/section3"
                android:layout_marginTop="10dip"
                android:layout_marginBottom="10dip"
                android:layout_below="@id/section2"> 
                <TextView android:id="@+id/l_tags_categories"
              android:layout_marginBottom="6dip"
              android:layout_width="fill_parent" 
              android:layout_height="wrap_content"
              android:text="Tags &amp; Categories"
              style="@style/WordPressSectionHeader"/>              
                   <TextView android:id="@+id/l_tags" 
              android:layout_width="fill_parent" 
              android:layout_height="wrap_content"
              android:layout_below="@id/l_tags_categories" 
              android:text="@string/tags_separate_with_commas"/>

    <EditText android:id="@+id/tags" 
              android:minHeight="40dip"
              android:layout_width="fill_parent" 
              android:layout_height="wrap_content" 
              android:background="@android:drawable/editbox_background"
              android:autoText="true"
              android:layout_below="@id/l_tags"/>

    <TextView android:id="@+id/l_category" 
              android:layout_width="fill_parent" 
              android:layout_height="wrap_content" 
              android:text="@string/categories"
              android:layout_below="@id/tags"
              android:layout_marginTop="10dip"/>

  <Button
            android:id="@+id/selectCategories"
            android:background="@drawable/wp_button_small"
            android:layout_below="@id/l_category"
            android:layout_width="wrap_content"  
            android:layout_height="wrap_content"
            android:textSize="18dip"
            android:text="@string/select_categories" />

     <TextView android:id="@+id/selectedCategories" 
              android:layout_width="wrap_content" 
              android:layout_height="wrap_content"
              android:text="@string/selected_categories"
              android:layout_below="@id/selectCategories"/>        
 </RelativeLayout> 
  <RelativeLayout android:id="@+id/location_wrapper"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
                android:layout_below="@id/section3"
                android:layout_marginTop="-10dip">
  <RelativeLayout android:layout_width="fill_parent" 
                android:layout_height="wrap_content"
                android:background="@drawable/content_bg"
                android:id="@+id/section4"
                android:layout_marginTop="10dip"
                android:layout_marginBottom="10dip"
                android:layout_below="@id/section3"
                android:visibility="gone"> 
                <TextView android:id="@+id/l_location"
              android:layout_marginBottom="6dip"
              android:layout_width="fill_parent" 
              android:layout_height="wrap_content"
              android:text="@string/location"
              style="@style/WordPressSectionHeader"/>
              <TextView android:id="@+id/locationText"
              android:layout_marginBottom="6dip"
              android:layout_width="fill_parent" 
              android:layout_height="wrap_content"
              android:text="@string/loading"
              android:layout_below="@id/l_location"/> 
              <Button
            android:id="@+id/viewMap"
            android:background="@drawable/wp_button_small"
            android:layout_below="@id/locationText"
            android:layout_width="wrap_content"  
            android:layout_height="wrap_content"
            android:textSize="18dip"
            android:text="View Map" />                                 
 </RelativeLayout> 
 </RelativeLayout>  
 <RelativeLayout android:layout_width="fill_parent" 
                android:layout_height="wrap_content"
                android:background="@drawable/content_bg"
                android:id="@+id/section5"
                android:layout_marginTop="10dip"
                android:layout_marginBottom="10dip"
                android:layout_below="@id/location_wrapper"> 
                <TextView android:id="@+id/l_status"
              android:layout_marginBottom="6dip"
              android:layout_width="fill_parent" 
              android:layout_height="wrap_content"
              android:text="@string/status"
              style="@style/WordPressSectionHeader"/>                                       
    <CheckBox android:id="@+id/publish"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:layout_below="@id/l_status"
            android:text="@string/publish"
            android:button="@drawable/wp_checkbox"
            /> 
 </RelativeLayout>            
<Button
            android:id="@+id/post"
            android:layout_width="wrap_content"  
            android:layout_height="wrap_content"
            android:layout_below="@id/section5"
            android:layout_alignParentRight="true"
            android:textSize="18dip"
            android:background="@drawable/wp_button"
            android:text="@string/save" />
<Button
            android:id="@+id/upload"
            android:layout_width="wrap_content"  
            android:layout_height="wrap_content"
            android:layout_alignBottom="@id/post"
            android:layout_toLeftOf="@id/post"
            android:textSize="18dip"
            android:background="@drawable/wp_button"
            android:text="@string/upload_now" />            
</RelativeLayout>
</ScrollView>

解决方案

From what i've read on a forums so far , having several scrollable containers on same screen is not a good idea. Now, those post were usually about listview , gridview in combination with scrollview but still to me it seems that the best solution redesign the screen to avoid that.

这篇关于内的EditText启用滚动这是一个滚动型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆