我有一个非常复杂的View构建,作为其中的一部分,我在ScrollView中的LinearLayout内部有一个ListView(还有很多组件,但在这个问题上它们并不重要).
现在整个活动滚动得很好,但ListView的高度有限,当它里面的项目超过高度时,我的屏幕消失了.我试图将ListView放在它自己的ScrollView中,但这不起作用.当我尝试在ListView上滚动时,选择了主ScrollView并且我的屏幕滚动而不是ListView.
我的问题可能听起来很简单,但我无法解决这个问题......是否有可能使ListView可滚动?
相关的XML:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:id="@+id/GlobalLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView android:id="@+id/EndpointList"
android:choiceMode="multipleChoice"
android:layout_height="175dip"
android:layout_width="fill_parent" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud) .NET UserControl(来自ScrollableControl)必须能够显示水平和垂直滚动条.
调用者可以设置这些水平和垂直滚动条的可见性和范围:
UserControl.AutoScroll = true;
UserControl.AutoScrollMinSize = new Size(1000, 4000); //1000x4000 scroll area
Run Code Online (Sandbox Code Playgroud)
注:在
UserControl(即ScrollableControl)使用的指定Windows标准的机制WS_HSCROLL和WS_VSCROLL窗口风格使滚动条显示.也就是说:它们不会创建单独的Windows或.NET滚动控件,将它们定位在窗口的右侧/底部.Windows有一个标准机制,用于显示一个或两个滚动条.
如果用户滚动控件,UserControl则发送一个WM_HSCROLL或WM_VSCROLL消息.为了响应这些消息,我希望ScrollableControl使客户区无效,这在本机Win32中会发生:
switch (uMsg)
{
case WM_VSCROLL:
...
GetScrollInfo(...);
...
SetScrollInfo(...);
...
InvalidateRect(g_hWnd,
null, //erase entire client area
true, //background needs erasing too (trigger WM_ERASEBKGND));
break;
}
Run Code Online (Sandbox Code Playgroud)
我需要整个客户区无效.问题是,用户控件(即ScrollableControl)调用的ScrollWindowAPI函数:
protected void SetDisplayRectLocation(int x, int y)
{
...
if ((nXAmount != 0) …Run Code Online (Sandbox Code Playgroud) 我已经多次尝试将RelativeLayout中的元素混淆但是我没有得到我期望的结果:

我想将第一个按钮对齐到右上角,然后我有多个Textview,我希望它们都是Scrollable,但是当我插入标签时出现错误,这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RL01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/btnBrowser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Browser"
android:layout_marginTop="5dp"
>
</Button>
<TextView
android:id="@+id/txtAuthor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dp"
android:textStyle="bold"
android:textColor="#143781"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp"
android:layout_below="@+id/btnBrowser"
>
</TextView>
<TextView
android:id="@+id/txtDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dp"
android:textColor="#8D89B3"
android:layout_marginTop="5dp"
android:layout_marginLeft="20dp"
android:layout_below="@+id/txtAuthor">
</TextView>
<TextView
android:id="@+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dp"
android:textStyle="bold"
android:textColor="#000000"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:layout_below="@+id/txtDate">
>
</TextView>
<TextView
android:id="@+id/txtMsg"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="14dp"
android:textColor="#000000"
android:layout_marginLeft="20dp"
android:layout_below="@+id/txtTitle">
</TextView>
<Button
android:id="@+id/btnReply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reply"
android:layout_marginTop="20dp"
android:layout_below="@+id/txtMsg"
android:layout_centerInParent="@+id/txtMsg">
</Button>
</ScrollView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 我想有一个可滚动的div,但滚动条应该在浏览器的右侧作为默认值(但不在div的右侧).我在facebook上看到过(ceter div - contentArea由右侧浏览器滚动条滚动).
典型的用例是包含两列的页面:

JQuery Mobile中的标准行为是内容与页面一起滚动.是否可以使用不同的范例使用JQM构建应用程序 - 具有可滚动内容的固定视口?
我正在使用draggableScrollableSheet. 我给这些参数
DraggableScrollableSheet(initialChildSize: 0.4,maxChildSize: 1,minChildSize: 0.4,builder: (BuildContext context, ScrollController scrollController) {
return SingleChildScrollView(controller: scrollController,
child: Theme(
data: Theme.of(context).copyWith(canvasColor: Colors.transparent),
child: Opacity(
opacity: 1,
child: IntrinsicHeight(
child: Column(mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
SizedBox(height: 10,),
Container(
margin: EdgeInsets.only(right: 300),
decoration: BoxDecoration(
border: Border(
top: BorderSide(
color: Colors.blue,
width: 3,
style: BorderStyle.solid),
),
),
),
Card(
child: Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Text(
S
.of(context)
.we_have_found_you_a_driver,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold), …Run Code Online (Sandbox Code Playgroud) 当前的问题看起来是这样的,如图所示,当滚动到标题后面时,内容仍然有点可见。如何解决这个问题并使内容在滚动到粘性标题后面时不可见?
.tableUpdates {
overflow-y: auto;
height: 250px;
}
.tableUpdates thead th {
position: sticky;
margin-top:0px;
top: 0;
background: #DC3545;
}Run Code Online (Sandbox Code Playgroud)
<div class="col-md-4 pr-0 tableUpdates">
<table class="table table-bordered table-hover">
<thead class="bg-danger text-light">
<tr>
<th>Header</th>
</tr>
</thead>
<tbody>
.....some rows
</tbody>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
ScrollableControl类有2个受保护的布尔属性:HScroll和VScroll.
正如文件所说:
获取或设置一个值,该值指示水平滚动条是否可见.
和
AutoScroll自动保持滚动条的可见性.因此,启用AutoScroll时,将HScroll或VScroll属性设置为true无效.
所以我像这样使用它们,但滚动条没有显示:
class MyScrollableControl : ScrollableControl {
public MyScrollableControl() {
this.AutoScroll = false;
this.HScroll = true;
}
}
Run Code Online (Sandbox Code Playgroud)
如果我使用以下代码,它的工作原理:
this.HorizontalScroll.Visible = true;
Run Code Online (Sandbox Code Playgroud)
当我把它们放在一起时,滚动条仍然是不可见的,并且HScroll和HorizontalScroll.Visible的值保持为False.
this.AutoScroll = false;
this.HScroll = true;
this.HorizontalScroll.Visible = true;
Run Code Online (Sandbox Code Playgroud)
那么HScroll和VScroll的真正用途是什么?
更新
我的代码和测试
我遇到了这个问题:
我有一个div(#container),它包含两个div.容器的高度应该是100%,不管这个div的内容是什么 - 不少于更多.
在这个div里面我想要两个全宽的div在彼此之上:
目前我有以下css ...
body {
margin:0;
padding:0;
}
#container
{
position: relative;
width: 500px;
height: 100%;
max-height: 100%;
background-color: #f00;
}
#upper {
width: 100%;
background-color: #0f0;
}
#lower {
width: 100%;
background-color: #00f;
overflow: auto;
}
Run Code Online (Sandbox Code Playgroud)
......以及这段代码:
<div id="container">
<div id="upper"></div>
<div id="lower"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
(#container)的高度如何正好100% - 与其内容无关?现在由于(#upper)和(#lower)的组合内容,高度变得更大了?
如何(#lower)可滚动(仅上下,而不是从左到右!)?
非常感谢您的反馈,我希望我们都能从中吸取教训.
我有一个位于Column小部件顶部的图像,之后有一个标题是Text小部件,之后,还有一个Text小部件包含一些描述,超出了屏幕并给出了渲染错误.
所以我想让文本视图可滚动,这样它应该完全可见并且可以滚动.它的大小必须是动态的,因为来自API的数据.我尝试了很少的方法,但无法完成.这是截图
截图:
@override
Widget build(BuildContext context) {
var size = MediaQuery
.of(context)
.size;
final double itemHeight = (size.height - kToolbarHeight - 24) / 2;
final double itemWidth = size.width;
return new Container(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Padding(
padding: const EdgeInsets.fromLTRB(0.0, 24.0, 0.0, 0.0),
child: new Image.asset(
'assets/img/noconnection.png',
height: 200.0,
width: itemWidth,
),
),
new Padding(
padding: const EdgeInsets.all(12.0),
child: new Text(
"Some Heading Text",
style: new TextStyle(
fontSize: 28.0,
color: Colors.black87,
fontWeight: FontWeight.w600),
),
), …Run Code Online (Sandbox Code Playgroud)