标签: scrollview

如何始终显示滚动条

滚动视图中的滚动条仅在我开始滚动时可见.我怎么能一直展示它?

android scrollview

236
推荐指数
12
解决办法
13万
查看次数

如何在Android中使用ScrollView?

我有一个XML布局文件,但文本不仅适合屏幕大小.为了制作一个,我需要做ScrollView什么?

<?xml version="1.0" encoding="utf-8"?>

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:stretchColumns="1" >

    <TableRow>
        <ImageView
            android:id="@+id/imageView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dip"
            android:layout_marginTop="10dip"
            android:layout_marginRight="5dip"
            android:tint="#55ff0000"
            android:src="@drawable/icon" />
    </TableRow>
    <TableRow>
        <TextView
            android:id="@+id/name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="3dip"
            android:text="  Name " />
        <TextView android:id="@+id/name1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="left"
            android:text="Veer" />
    </TableRow>
    <TableRow>
        <TextView android:id="@+id/age"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="3dip"
            android:text="  Age" />

        <TextView android:id="@+id/age1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="left"
            android:text="23" />
    </TableRow>
    <TableRow>
        <TextView android:id="@+id/gender"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="3dip"
            android:text="  Gender" />
        <TextView android:id="@+id/gender1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="left"
            android:text="Male" />
    </TableRow>
    <TableRow>
        <TextView android:id="@+id/profession"
            android:layout_width="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android scrollview

222
推荐指数
5
解决办法
60万
查看次数

有没有办法以编程方式将滚动视图滚动到特定的编辑文本?

我有一个很长的活动与scrollview.这是一个包含用户必须填写的各种字段的表单.我的表单中有一个复选框,当用户检查它时,我想滚动到视图的特定部分.有没有办法以编程方式滚动到EditText对象(或任何其他视图对象)?

此外,我知道这可能使用X和Y坐标,但我想避免这样做,因为表单可能会从用户更改为用户.

android view scrollview android-edittext programmatically-created

187
推荐指数
10
解决办法
13万
查看次数

Android:如何检查ScrollView中的View是否可见?

我有一个ScrollView持有一系列的Views.我希望能够确定一个视图当前是否可见(如果当前显示它的任何部分ScrollView).我希望下面的代码可以做到这一点,令人惊讶的是它没有:

Rect bounds = new Rect();
view.getDrawingRect(bounds);

Rect scrollBounds = new Rect(scroll.getScrollX(), scroll.getScrollY(), 
        scroll.getScrollX() + scroll.getWidth(), scroll.getScrollY() + scroll.getHeight());

if(Rect.intersects(scrollBounds, bounds))
{
    //is  visible
}
Run Code Online (Sandbox Code Playgroud)

android scrollview visible

160
推荐指数
11
解决办法
8万
查看次数

如何滚动到长ScrollView布局的顶部?

对于我的部分应用,会向用户显示一个名称列表,并要求他们按照自己的意愿对其进行分组.

(注意,ListView代码是从Android视图教程中逐字复制的.我还没有根据我的需要对其进行定制,我只想弄清楚如何使其工作.)

基本布局是一个LinearLayout,包含一个ScrollView(在下面的代码中称为"groupsScrollView"),包含一个RelativeLayout.我有一些按钮和文本,然后是我的ListView,它显示了名称列表.所有这一切都高于可见屏幕区域,因此允许用户垂直滚动以查看所有内容.

这一切都很漂亮,除非页面加载时总是预先滚动到我的ListView顶部 - 在页面中间.我创建的文本和按钮告诉用户该做什么是不可见的.

我可以抓住屏幕并向上滚动,这很好用,但我希望屏幕加载已经滚动到顶部.用户不必向上滚动以查看新加载页面的顶部.但我尝试以编程方式滚动到屏幕顶部的所有内容都失败了.

这是我的onCreate方法:

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.groups);

    mainScrollView = (ScrollView)findViewById(R.id.groupsScrollView);

    //get the Bundle out of the Intent...
    Bundle extras = getIntent().getExtras();
    mNames = extras.getStringArray("mNames");

    setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, mNames));

    ListView lv = getListView();
    lv.setTextFilterEnabled(true);

    //This is the line I'm having issues with
    mainScrollView.pageScroll(View.FOCUS_UP);

    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view,
            int position, long id) {
          // When clicked, show a toast with the TextView text
          Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
              Toast.LENGTH_SHORT).show();
        }
      }); …
Run Code Online (Sandbox Code Playgroud)

android listview scrollview

156
推荐指数
12
解决办法
15万
查看次数

ScrollView中的ListView不在Android上滚动

我在滚动ListView里面遇到麻烦ScrollView.我有一个Activity在顶部有一些EditTexts,然后是一个带有两个选项卡的选项卡主机,每个选项卡都有一个ListView.当EditText视图聚焦时,软键盘出现,因为我有一个ScrollView,内容是可滚动的.但问题出现在ListViews中有更多项目(选项卡中的项目),即使有更多项目,我也无法滚动ListView.

以下是布局XML:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="?backgroundImage"
    android:orientation="vertical">

  <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="50dip"
        android:layout_alignParentBottom="true"
        android:layout_margin="10dip"
        android:id="@+id/buttons">
    <Button
            android:text="Save"
            android:layout_margin="2dip"
            android:textSize="20dip"
            android:id="@+id/btnSaveorUpdate"
            android:layout_height="wrap_content"
            android:layout_width="145dip"></Button>
    <Button
            android:text="Cancel"
            android:layout_margin="2dip"
            android:textSize="20dip"
            android:id="@+id/btnCancelorDelete"
            android:layout_height="wrap_content"
            android:layout_width="145dip"></Button>
  </LinearLayout>
  <ScrollView
        android:layout_above="@id/buttons"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fillViewport="true"
        android:layout_margin="10dip">
    <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_margin="10dip">
      <TextView
                android:text="Bill details"
                android:textColor="?textColorDark"
                android:layout_alignParentTop="true"
                android:id="@+id/txtEnterDetails"
                android:textSize="25dip"
                android:textStyle="bold"
                android:layout_height="wrap_content"
                android:layout_width="fill_parent"
                android:layout_marginBottom="2dip"></TextView>
      <LinearLayout
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:layout_width="0dip"
                android:layout_height="0dip" />
      <EditText
                android:layout_width="fill_parent"
                android:hint="Enter data"
                android:inputType="numberDecimal"
                android:id="@+id/txtSample"
                android:textSize="@dimen/editText"
                android:layout_height="@dimen/editTextHeight"
                android:text=""></EditText>
      <EditText
                android:layout_width="fill_parent"
                android:id="@+id/txtDescription"
                android:hint="Enter description"
                android:textSize="@dimen/editText" …
Run Code Online (Sandbox Code Playgroud)

android listview scrollview android-layout

151
推荐指数
9
解决办法
20万
查看次数

Scrollview在android中纵向和横向

我真的很想找到垂直和水平Scrollview的解决方案.

我读到框架中没有任何实现此功能的视图/布局,但我需要这样的东西:

我需要在其他内部定义布局,子布局必须实现滚动垂直/水平移动.

最初实现了一个逐像素移动布局的代码,但我认为这不是正确的方法.我尝试使用ScrollView和Horizo​​ntal ScrollView,但没有任何工作像我想要的那样,因为它只实现垂直或水平滚动.

Canvas不是我的解决方案,因为我需要在某些子元素中附加侦听器.

我能做什么?

android scrollview

146
推荐指数
8
解决办法
20万
查看次数

我可以在Android中以编程方式滚动ScrollView吗?

有没有办法以ScrollView编程方式滚动到某个位置?

我创建了动态TableLayout,放在一个ScrollView.所以我希望在特定的操作(如点击按钮等)上,特定的行应自动滚动到顶部位置.

可能吗?

java android scrollview android-scrollview

141
推荐指数
9
解决办法
15万
查看次数

首先在孩子的父母上调用removeView()

首先是一点背景:

我在scrollview中有一个布局.首先,当用户在屏幕上滚动时,滚动视图滚动.但是,经过一定量的滚动后,我要禁用滚动视图上的滚动,将"滚动焦点"移动到子布局内的webview上.这样,scrollview会将所有滚动事件都粘贴到其中的webview中.

因此,对于解决方案,当达到滚动阈值时,我从scrollview中删除子布局并将其放在scrollview的父级中.(并使scrollview不可见).

// Remove the child view from the scroll view
scrollView.removeView(scrollChildLayout);

// Get scroll view out of the way
scrollView.setVisibility(View.GONE);

// Put the child view into scrollview's parent view
parentLayout.addView(scrollChildLayout);
Run Code Online (Sandbox Code Playgroud)

一般理念:( - >表示包含)

之前:parentlayout - > scrollview - > scrollChildLayout

之后:parentLayout - > scrollChildLayout

上面的代码给了我这个例外:

java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
           at android.view.ViewGroup.addViewInner(ViewGroup.java:1976)
           at android.view.ViewGroup.addView(ViewGroup.java:1871)
           at android.view.ViewGroup.addView(ViewGroup.java:1828)
           at android.view.ViewGroup.addView(ViewGroup.java:1808)
Run Code Online (Sandbox Code Playgroud)

你知道发生了什么吗?我显然在父级上调用了removeView.

android scrollview

135
推荐指数
5
解决办法
18万
查看次数

我可以为ScrollView使用onScrollListener吗?

HorizontalScrollView在布局中使用a ,我需要确定用户已达到滚动的起点和终点.

因为ListView我已经尝试过了onScrollListener,可以找到滚动的起点和终点.

我尝试在我做同样的事情,Scrollview但似乎不可能.有没有其他可能的方法来实现我的需要.

提前致谢.

android listener scrollview

134
推荐指数
6
解决办法
13万
查看次数