我在ScrollViews上遇到了很多问题.最近我尝试创建一个内容超出屏幕大小的LinearView,因此我使用父元素ScrollView创建了新的布局,并将其宽度和高度设置为自定义值(布局必须显示为对话框 - 不填充整个屏幕).
选择元素后,红色边框将显示为包含预定义ScrollView LayoutWidth和LayoutHeight的矩形,即可.然后我放入LinearView并将值LayoutWidth和LayoutHeight设置为fill_parent.
然后,当我开始将元素添加到LinearLayout时,边框(红色lile)包装了插入的元素,而不是整个父ScrollView.
因此,当LinearLayout(ScrollView的子节点)的内容超出父ScrollView的大小时,滚动没有出现,底部元素只是不可见.
无论如何..在这种情况下,XML内容过于庞大,无法在此处发布问题,现在我对更简单的示例遇到了同样的问题.
布局的以下部分旨在是可滚动的EditText(在用户输入超过窗口小部件的主要大小的情况下).我想将EditText高度设置为120px,因此我将父ScrollView高度设置为120px,将子EditText设置为fill_parent.同样在这种情况下,EditText不会填充整个ScrollView区域,而是一行:
<ScrollView android:layout_height="120px" android:layout_width="fill_parent">
<EditText android:id="@+id/txtContent" android:layout_height="fill_parent" android:layout_width="fill_parent" android:text="TestContent">
</EditText>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
有谁知道如何重塑上面的内容,以便EditText填充父控件,如果用户的输入超过控件大小,滚动出现?
谢谢!
编辑:
以下是布局的屏幕截图
删除死了的ImageShack链接
删除了死ImageShack链接
我必须将WebView放入ScrollView.但是我必须在webview之前将一些视图放到同一个scrollview中.所以它看起来像这样:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:id="@+id/articleDetailPageContentLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/articleDetailRubricLine"
android:layout_width="fill_parent"
android:layout_height="3dip"
android:background="@color/fashion"/>
<ImageView
android:id="@+id/articleDetailImageView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitStart"
android:src="@drawable/article_detail_image_test"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dip"
android:text="PUBLISH DATE"/>
<WebView
android:id="@+id/articleDetailContentView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/fashion"
android:isScrollContainer="false"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我从后端获得了一些HTML信息.它没有任何身体或头部标签,只有被<p>或<h4>或其他标签包围的数据.它还有<img>标签.有时图片对于当前屏幕宽度来说太宽.所以我在HTML的开头添加了一些CSS.所以我将数据加载到webview,如下所示:
private final static String WEBVIEW_MIME_TYPE = "text/html";
private final static String WEBVIEW_ENCODING = "utf-8";
String viewport = "<head><meta name=\"viewport\" content=\"target-densitydpi=device-dpi\" /></head>";
String css = "<style type=\"text/css\">" +
"img {width: 100%;}" +
"</style>";
articleContent.loadDataWithBaseURL("http://", viewport + css + articleDetail.getContent(), …Run Code Online (Sandbox Code Playgroud) 我已经搜索了很多关于我的查询,但没有一个是有用的.我在一个滚动视图中有一个recyclerview和一些静态数据,它位于root parentlayout中,如下所示.
我已经设定 -
scrollview.scrollto(0,0);
Run Code Online (Sandbox Code Playgroud)
因为每当我打开活动时它会跳转到recyclerview firstitem并且它会跳过recyclerview上方的静态数据.
recyclerview.setNestedScrollingEnabled(false);
recyclerview.setfocusable(false);
Run Code Online (Sandbox Code Playgroud)
对于smoothscroll.
问题是 -
layoutmanager.scrollToPositionWithOffset(pos,0);
Run Code Online (Sandbox Code Playgroud)
它不起作用.我在将适配器设置为recyclerview后设置了aboveline.也尝试使用NestedScrollView但是徒劳无功.
虽然我用过
layoutmanager.scrollToPosition(pos);
Run Code Online (Sandbox Code Playgroud)
对于那些跳过代码的人,我已将match_parent设置为ScrollView,并将fillviewport设置为true.
这是我的布局.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/bottomsheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.inkdrops.khaalijeb.BrandCouponActivity">
<RelativeLayout
android:id="@+id/inclusionviewgroup"
android:layout_width="match_parent"
android:layout_height="match_parent">
<static data/>
<ScrollView
android:id="@+id/scrollviewmain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/one"
android:fillViewport="true"
android:scrollbars="none"
android:layout_above="@+id/donelayout">
<staticdata/>
<TextView
android:id="@+id/dealstext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/card1"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:textSize="16sp"
android:text="Deals & Coupons"
android:textColor="#444444" />
<RelativeLayout
android:id="@+id/recyclerlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/dealstext"
android:layout_marginTop="5dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:background="@color/colorbackground">
<android.support.v7.widget.RecyclerView
android:id="@+id/coupon_rec_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorbackground"
android:visibility="visible"/>
</RelativeLayout>
<statisdata>
</RelativeLayout>
</ScrollView>
include layout="@layout/activity_coupons"
android:visibility="gone"
/> …Run Code Online (Sandbox Code Playgroud) android scrollview android-recyclerview linearlayoutmanager android-nestedscrollview
我有一个根scrollview元素,其中包含一个relativelayout,以及相对布局中的一堆表单元素.
出于某种原因,当软键盘打开时,它似乎无法一直滚动到底部,这将我的一个按钮切成两半.
以下是层次结构查看器的屏幕截图,用于演示我的意思.

如您所见,系统知道视图继续通过键盘,但滚动视图(正确填充屏幕的可见部分)将不会继续向下滚动.
我有android:windowSoftInputMode="adjustResize"活动的清单,我可以/不会把它切换到平底锅.
任何帮助表示赞赏.
编辑:我在多个视图中看到这个.这是另一个具有相同问题的视图的xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/background" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="32dp" >
<EditText
android:id="@+id/reset_oldpass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:ems="10"
android:singleLine="true"
android:hint="@string/current_password"
android:layout_marginTop="16dp" />
<EditText
android:id="@+id/reset_pass1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/reset_oldpass"
android:ems="10"
android:hint="@string/reset_new_pass"
android:inputType="textPassword"
android:layout_marginTop="16dp" />
<EditText
android:id="@+id/reset_pass2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/reset_pass1"
android:ems="10"
android:hint="@string/reset_confirm_pass"
android:inputType="textPassword"
android:layout_marginTop="16dp" />
<TextView
android:id="@+id/reset_forgot_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/reset_pass2"
android:layout_marginTop="16dp"
android:textColor="@color/Link"
android:textStyle="bold"
android:text="@string/Login_forgot_password" />
<Button
android:id="@+id/reset_reset_password_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/reset_forgot_password"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:layout_marginBottom="32dp"
android:text="@string/reset_change_pass" /> …Run Code Online (Sandbox Code Playgroud) 我是React Native的新手,所以我可能会问一些非常明显的事情,但请帮忙.
我有一个可触摸的视图,所以整个区域响应攻丝.然后将ScrollView嵌套在视图中.整体结构是这样的:
<TouchableWithoutFeedback onPress={this.handlePress.bind(this)}>
<View>
<ScrollView>
<Text>Hello, here is a very long text that needs scrolling.</Text>
<ScrollView>
</View>
</TouchableWithoutFeedback>
Run Code Online (Sandbox Code Playgroud)
编译并运行时,会检测到点击,但滚动视图根本不会滚动.我使上面的代码简洁明了,但每个组件都有正确的样式,我可以看到所有渲染都很好,长文本在ScrollView的底部被截断.请帮忙.
谢谢!
我的表格大约有12/13个字段.我Scrollview在约束布局中使用了一个内部.下面是XML布局的层次结构.问题是,它不会滚动到底部而是仅滚动到前10个初始视图.最后3个字段被隐藏,因为视图不再滚动.
父母布局
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_register"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
android:orientation="vertical">
<!-- Textview and a button -->
<ScrollView
android:id="@+id/scrollView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:overScrollMode="never"
android:scrollbars="none"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/view"
tools:layout_constraintBottom_creator="1"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintTop_creator="1"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp">
<android.support.constraint.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Child Views (12/13 views of the fields)-->
</android.support.constraint.ConstraintLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud) android constraints scrollview android-layout android-constraintlayout
我希望能够在 SwiftUI 中调整大小和移动图像(就像它是地图一样),并通过捏来缩放和拖动它。
使用 UIKit 我将图像嵌入到 a 中UIScrollView并处理它,但我不知道如何在 SwiftUI 中执行此操作。我尝试使用,MagnificationGesture但我无法让它顺利工作。
我已经搜索了一段时间了,有没有人知道是否有更简单的方法?
我添加了一个scrollView,如果在Android平板电脑上部署,它有一些问题.但它在手机上运行良好.
当用户移动到整个页面的顶部或底部时,它将自动显示蓝色阴影,表示用户到达页面底部.我想删除这些指标,因为它会影响用户界面.
有没有办法删除或设置XML?
我已尝试在scrollview上设置不同的参数,但它不起作用.
请帮忙.
我正在Swift 2.0中开发一个小应用程序.我有一个具有以下层次结构的视图:
现在,放置在此视图中的元素无法完全显示在其中,因此我想使用a ScrollView以便能够滚动所有内容.
如何将我的所有内容嵌入View到新内容中ScrollView?我可以通过代码以编程方式执行此操作吗
我在这个特定问题上找到的最好的(尽管我不使用图库):ScrollView和Gallery干扰 - 虽然没有给出具体的答案.显然,我的实现不使用Gallery.
跳转到有趣部分的下一个大胆部分
因此,我的Fling/Swipe/Flick /无论您想要在我的应用程序上将其称为工作片段.灵感来自几个不同的地方,其中一些是Stack Overflow上的"基本手势检测"(网格布局上的手势检测),Code Shogun(http://www.codeshogun.com/blog/2009/04/16 /如何实现-swipe-action-in-android /)和开发Android(http://developingandroid.blogspot.com/2009/09/implementing-swipe-gesture.html),但我不使用我的应用程序中的ViewFlipper.当发生甩尾时,我只需更换标签(在末端缠绕).
现在,我的一些标签包含ScrollViews.这些ScrollViews显然会响应向上/向下滚动,以便让您查看其中的所有数据,这并不奇怪.问题是看起来这些ScrollViews的"滚动"功能会覆盖我的手势.我不能在ScrollView内部滚动(滚动得很好),但它在它们之外完美无缺(在同一个选项卡上,在TableRow等其他视图上).
我快速浏览了http://blog.velir.com/index.php/2010/11/17/android-snapping-horizontal-scroll/,它提供了一种实现HorizontalScrollView的方法.但它仍然通过扩展SimpleOnGestureListener(并覆盖onFling)的类来处理手势,这与我的实现相同(这使我相信它不会真正有用).来自Google的ScrollView的源代码:http://google.com/codesearch/p? hl = en#uX1GffpyOZk/core/java/android/widget/ScrollView.java&d = 3
有没有办法让我的Swipe和ScrollView的实现毫不费力地协同工作?
我想这就是问题所在.ScrollView.java还使用一个名为onTouchEvent的方法和onTouchEvent for Activity状态的文档:
"当触摸屏事件未被其下的任何视图处理时调用.这对于处理在窗口范围之外发生的触摸事件非常有用,其中没有视图可以接收它."
所以ScrollView会"覆盖"它 - 我该怎么办?有没有办法确保两者都被检查?我的onTouchEvent在ScrollView处理onTouchEvent时没有被击中:
@Override
/** Used for swipe gestures */
public boolean onTouchEvent(MotionEvent event) {
if (gestureDetector.onTouchEvent(event))
return true;
else
return false;
}
Run Code Online (Sandbox Code Playgroud)
下面是更一般的源代码,它可能不是很重要.我的Tabs类中的gestureDetector及其关联的侦听器:
// Gestures
gestureDetector = new GestureDetector(new MyGestureDetector());
gestureListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (gestureDetector.onTouchEvent(event)) …Run Code Online (Sandbox Code Playgroud) scrollview ×10
android ×7
scroll ×2
swift ×2
constraints ×1
image ×1
ios ×1
layout ×1
pinchzoom ×1
react-native ×1
shadow ×1
swiftui ×1
swipe ×1
tablet ×1
webview ×1