我有一个包含Android应用中的textview的scrollview.此文本视图将按设定的间隔连续添加文本.滚动工作和文本添加正常,但我想做的是在添加文本时使scrollview自动滚动.当新文本附加在底部时,它会自动向下滚动以匹配,并且旧文本在顶部被推出视线之外.更好的是将文本添加到滚动视图的底部并让它向上推动旧文本,但一次只能做一件事.
我是一个Android开发人员.我也想使用ScrollView.This ScrollView需要一段时间禁用滚动和一些时间启用滚动.但我无法禁用滚动.如何实现它.请帮助我.我也尝试使用一些代码,如
fullparentscrolling.setHorizontalFadingEdgeEnabled(false);
fullparentscrolling.setVerticalFadingEdgeEnabled(false);
Run Code Online (Sandbox Code Playgroud)
要么
fullparentscrolling.setEnabled(false);
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我试图在React Native for Android中使用水平ScrollView,其中起始位置位于滚动图像的中间而不是(0,0).
该scrollTo方法似乎在内部正确调用,componentDidMount但在应用程序中没有任何移动,它仍然显示为从左侧开始滚动.
由于这是Android,我没有访问contentOffset道具或我会直接设置,根据文档.这是代码:
'use strict';
var React = require('react-native');
var {
StyleSheet,
View,
Text,
ScrollView,
Component,
} = React;
var precomputeStyle = require('precomputeStyle');
class Carousel extends Component {
constructor(props, context) {
super(props, context);
//this.changeContent = this.changeContent.bind(this);
}
componentDidMount() {
this.myScroll.scrollTo(100);
console.log("called DidMount");
}
render() {
return (
<View style={{flex: 1}}>
<ScrollView ref={(ref) => this.myScroll = ref}
contentContainerStyle={styles.container}
horizontal={true}
pagingEnabled={true}
showsHorizontalScrollIndicator={false}
bounces={true}
onMomentumScrollEnd={this.onAnimationEnd}
>
{this.props.children}
</ScrollView>
</View>
);
}
onAnimationEnd(e) { …Run Code Online (Sandbox Code Playgroud) 我ScrollView在我的Android布局中使用但它显示
IllegalStateException "Scrollview can host only one direct child"
我怎样才能避免这种异常?
崩溃信息:
07-19 15:58:22.308 21372 21372 D AndroidRuntime: Shutting down VM
07-19 15:58:22.313 21372 21372 E AndroidRuntime: FATAL EXCEPTION: main
07-19 15:58:22.313 21372 21372 E AndroidRuntime: Process: com.languoguang.helloworld, PID: 21372
07-19 15:58:22.313 21372 21372 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.languoguang.helloworld/com.languoguang.helloworld.plugin_homeadd.activity.AddDeviceWifiSettingActivity}: android.view.InflateException: Binary XML file line #254: ScrollView can host only one direct child
07-19 15:58:22.313 21372 21372 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3190)
07-19 15:58:22.313 21372 21372 E AndroidRuntime: …Run Code Online (Sandbox Code Playgroud) 是否可以将适配器设置为LinearLayout?
ListView因为我正在使用,所以我不想使用ScrollView.所以我用LinearLayout...
在那我是动态添加视图,现在我需要使用适配器..所以任何人有任何建议?
我这样做......
LinearLayout clientList = (LinearLayout) findViewById(R.id.clients);
adapter = new Sample1AdapterActivity(this, arrayList);
View list = (ListView) getLayoutInflater().inflate(R.layout.user_details, getListView(), false);
Run Code Online (Sandbox Code Playgroud) 我的页面代码是这样的.我需要在appbar下方滚动部分.
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(... ),
body: new Stack(
children: <Widget>[
new Container(
decoration: BoxDecoration(
image: DecorationImage(...),
new Column(children: [
new Container(...),
new Container(...... ),
new Padding(
child: SizedBox(
child: RaisedButton(..),
),
new Divider(),
new Column(
children: <Widget>[
new Container(
child: new Row(
children: <Widget>[
new Expanded(
child: new Text( ),
),
new IconButton(
icon: IconButton(..),
onPressed: () {
_changed(true, "type");
},
),
],
),
),
visibilityPropertyType
? new Container(
margin: EdgeInsets.all(24.0),
child: …Run Code Online (Sandbox Code Playgroud) 如何在 VStack 中获得空间来将按钮固定在底部?
ScrollView {
VStack() {
Text("Title_1")
.padding(.bottom, 35.0)
Text("Title_2")
.padding(.bottom, 32.0)
Text("Title_3")
.padding(.bottom, 27.0)
Spacer()
Button(action: { print("ACTION") }) {
Text("OK")
.font(.title)
.fontWeight(.semibold)
.foregroundColor(Color.red)
}
.frame(height: 35)
.cornerRadius(8.0)
.padding(.bottom, 25.0)
}
.frame(maxWidth: .infinity)
}
Run Code Online (Sandbox Code Playgroud)
我最近将笔记本电脑升级为 Macbook M1 pro。我有一个滚动视图,当我用三个手指在我的旧 Macbook Air 上拖动时,它会惯性滚动。
现在有了 M1 芯片,滚动时就没有惯性了。我将 iOS 模拟器更改为使用 Rosetta,但滚动仍然不像以前那样平滑。
还有什么方法可以像我们在浏览器中使用的那样通过两根手指滑动来在 iOS 模拟器中滑动滚动视图?我的应用程序有很多滚动视图,这对我来说很重要。
我有点坚持这一个 - 首先,下面的链接已经然而有用的,我想出了一个有点能见度的问题:
链接:检查视图可见性
我有一个滚动视图(父)和若干子视图(LinearLayout- > TableLayout)等有许多项的予设定为View.GONEXML中(android:visibility="gone").
我有一些简单的代码来确定它是否可见getVisibility()但是当我设置项目View.VISIBLE并尝试立即getDrawingRect()我得到一个带有零的Rect.任何进一步点击都会得到正确的坐标
现在,这可能是因为观点从来没有抽(如XML定义),使其返回没有坐标然而,我设置View.VISIBLE试图确定屏幕可视性之前.可能是因为我需要从onDraw()获得某种回调吗?或者可能在代码中设置隐藏项目的视图可见性.有点烦人;(
一些代码:
Rect scrollBounds = new Rect();
scroll.getHitRect(scrollBounds);
Rect viewBounds = new Rect();
if (view.getVisibility() == View.GONE) {
view.setVisibility(View.VISBLE)
viewBounds.getDrawingRect(viewBounds);
if (!Rect.intersects(scrollBounds, viewBounds) {
// do somthing
}
}
Run Code Online (Sandbox Code Playgroud)
布局区域如下:
ScrollView
LinearLayout
TableLayout
ButtonHiddenView当然,我很可能完全以错误的方式解决这个问题 - 基本上我只是想确保scrollview定位自己以便可以看到已经变得可见的视图.
如果需要任何其他信息,请告诉我!
我有一个简单的布局如下:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#D23456" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#FFFFFF" >
<ImageView
android:layout_width="match_parent"
android:layout_height="800dp"
android:src="@drawable/ic_launcher" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
scrollview的背景是粉红色,线性布局里面有android图标图像,高度为800dp(不适合屏幕).我期待看到的是,imageview浮动在粉红色的背景中,每边(顶部,底部,左侧,右侧)的边距为10dp.但是当我滚动到底部时,滚动视图不会滚动到保证金,所以滚动的底部是imageview而不是粉红色的边距.
我怎么能阻止这个?这使用户认为页面尚未结束并使他想要滚动更多.
scrollview ×10
android ×5
autoscroll ×1
dart ×1
flutter ×1
ios ×1
java ×1
react-native ×1
swift ×1
swiftui ×1
textview ×1
view ×1
visibility ×1
vstack ×1
xcode ×1