标签: android-scrollview

在 onclick 侦听器上的活动底部滚动

在我的 Android 应用程序中,我有一些最初不可见的视图(按钮、EditTexts 等)。这些仅在特定按钮单击事件上可见。我希望将滚动视图移动到这些视图的末尾,以便用户可以看到这些视图。

布局文件的相关部分:

    <ScrollView...>

    <RelativeLayout android:id="@+id/RelDevDet"
            android:layout_width="fill_parent" android:layout_height="wrap_content">
            .
            .
            .
            <ImageButton android:id="@+id/ibRateApp"
                android:layout_toRightOf="@id/tvRateApp"
                android:layout_alignTop="@id/tvRateApp"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:background="@drawable/arrow_up" android:clickable="true"
                android:layout_marginRight="5dp"
                android:paddingBottom="10dp"
                 />
            <RatingBar android:id="@+id/rtApp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/tvRateApp"
                android:layout_marginLeft="5dp" android:visibility="gone"/>
            <EditText android:layout_width="fill_parent"
                android:id="@+id/etRateApp"
                android:layout_height="wrap_content" 
                android:lines="3"
                android:layout_below="@+id/rtApp"
                android:layout_marginRight="5dp"
                android:layout_alignLeft="@+id/tvDevWeb"
                android:visibility="gone" />
            <Button android:id="@+id/btSubRat" android:layout_width="fill_parent" android:layout_height="wrap_content"
                android:layout_below="@+id/etRateApp" android:layout_margin="5dp" android:text="Submit" android:visibility="gone"/>
        </RelativeLayout>
        </ScrollView>
Run Code Online (Sandbox Code Playgroud)

该按钮的 onclicklistener 是:

public void onClick(View v) {
if(v.getId()== R.id.ibRateApp){
            Log.d("amit","scroll end");
            rtApp.setVisibility(View.VISIBLE);
            etRateApp.setVisibility(View.VISIBLE);
            //How to get the scrollview move to the end of the page here??
        }
}
Run Code Online (Sandbox Code Playgroud)

android android-scrollview

1
推荐指数
1
解决办法
7976
查看次数

视图内的 ReactNative ScrollView

我试图在 ReactNative 的 View 中创建一个滚动视图。由于某种原因,我无法在 ScrollView 中滚动。

render() {
    return (
      <View>
        <View>
          <Text>Top</Text>
        </View>
        <ScrollView >
          <Text>Line 1</Text>
          <Text>Line 2</Text>
          <Text>Line 3</Text>
          <Text>Line 4</Text>
          <Text>Line 5</Text>
          <Text>Line 6</Text>
          <Text>Line 7</Text>
          ...
        </ScrollView>
      </View>
    );
  }
Run Code Online (Sandbox Code Playgroud)

这里有什么问题吗?我在 Android 上测试

谢谢,马格努斯

android android-scrollview react-native

1
推荐指数
1
解决办法
3712
查看次数

如何将 Webview 放在其他视图下方并将所有视图一起滚动

我正在开发一个 android 应用程序,我在其他视图下面有一个 webview。

整个内容不适合屏幕,所以我想启用一些滚动。

我的布局文件如下所示:

<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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    tools:layout_editor_absoluteX="8dp"
    tools:layout_editor_absoluteY="8dp">

    <TextView .../>
    <TextView .../>
    <TextView .../>
    <TextView .../>

    <WebView
        android:id="@+id/about_detail"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="24dp"
        android:textSize="14sp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/contactInformation"
        tools:layout_constraintLeft_creator="1"
        tools:layout_constraintRight_creator="1"
        tools:layout_constraintTop_creator="1" />

</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

我应该在 ConstraintLayout 周围使用 Scrollview,或者我该怎么做?

android scroll android-webview android-scrollview android-constraintlayout

1
推荐指数
1
解决办法
1230
查看次数

ScrollView 中的 ConstraintLayout 不滚动

我有一个带有标题、5 个 TextView、5 个 Spinner 和 2 个按钮的屏幕,这导致第 5 组 TextView/Spinner 向底部移出屏幕。我已经搜索过在 ConstraintLayout 中有一个 ScrollView 并尝试了我发现的各种事情,将特定的高度和宽度设置为“0dp”并将约束添加到 ScrollView 本身,但仍然唯一发生的事情是出现了 5 个集合,但是仍然不可滚动。我看到了一个与此类似的问题,但它们的底部没有任何内容,因此它们限制在父级的底部。我需要限制在底部按钮的顶部,以便我的按钮保持原位,只有中间滚动,但是当我将底部约束设置为按钮顶部时,整个视图消失了。

这是我当前的 XML

<?xml version="1.0" encoding="utf-8"?>
   <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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="teamtriplej.com.lipidlator21.CardiolipinsActivity">

<Button
    android:id="@+id/btnSubmit"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="30dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="16dp"
    android:background="@android:color/black"
    android:text="@string/Submit"
    android:textColor="@android:color/white"
    android:textStyle="bold"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.761"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent" />

<Button
    android:id="@+id/btnBack"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="30dp"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="8dp"
    android:background="@android:color/black"
    android:text="@string/Back"
    android:textColor="@android:color/white"
    android:textStyle="bold"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.216"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent" />

<TextView
    android:id="@+id/tvTitle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginTop="35dp"
    android:text="@string/CLConfiguration"
    android:textAlignment="center"
    android:textColor="@android:color/black"
    android:textSize="24sp"
    android:textStyle="bold"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    android:layout_marginStart="8dp" …
Run Code Online (Sandbox Code Playgroud)

android android-scrollview android-studio android-constraintlayout

1
推荐指数
1
解决办法
5305
查看次数

Fragment 工具栏上方奇怪的空白区域。如何解决?

我正在编写一个 Android 应用程序,它基于 Fragments,插入根 emty 活动中。对于每个片段,我配置了单独的工具栏。当我打开第一个屏幕片段时,它工作正常。此屏幕的xml、工具栏代码和屏幕截图

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

<android.support.design.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
        <include
                android:id="@+id/toolbar_main"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                layout="@layout/layout_toolbar_main"/>

        <android.support.v7.widget.RecyclerView
                android:id="@+id/listOfClientsWithActions"
                android:layout_height="match_parent"
                android:scrollbars="vertical"
                android:layout_width="match_parent"
                android:clipToPadding="false" android:paddingTop="8dp"/>
    </LinearLayout>

    <android.support.design.widget.FloatingActionButton
            android:id="@+id/fabAddContact"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end|bottom"
            android:src="@drawable/ic_baseline_add_white_24"
            android:layout_margin="16dp" app:fabSize="normal"/>
</android.support.design.widget.CoordinatorLayout>

<android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:itemIconTint="@color/drawer_item"
        app:menu="@menu/drawer_menu"
        app:itemTextAppearance="@style/NavDrawerItem"
        app:headerLayout="@layout/nav_header"/>
</android.support.v4.widget.DrawerLayout>

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)
    initToolbar(view)
}

private fun initToolbar(view: View) {
    val toolbar = view.findViewById<Toolbar>(R.id.toolbar_main)
    (activity …
Run Code Online (Sandbox Code Playgroud)

android android-linearlayout android-fragments android-scrollview android-actionbar

1
推荐指数
1
解决办法
1143
查看次数

在Android中使用滚动视图

如何在Android中正确使用Scroll.I必须将我的布局的一部分放入滚动视图.请帮助我得到这个

我的XML文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <LinearLayout
        android:id="@+id/headerLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:background="@drawable/top_bg"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/back_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="5dp"
            android:onClick="goBack"
            android:src="@drawable/back_button" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="75dp"
            android:layout_marginTop="10dp"
            android:text="Traveller Details"
            android:textColor="@android:color/white" />
    </LinearLayout>
   <!-- from here i want to put it into a scroll view -->
    <LinearLayout 
        android:id="@+id/tittleLayout"
        android:layout_below="@+id/headerLayout"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_marginTop="5dp"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/TittleTravellerDetails"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="5dp"
            android:gravity="left"
            android:text="Traveller Details" />

        <View
            android:layout_width="wrap_content"
            android:layout_height="2dip"
            android:layout_marginTop="2dp"
            android:background="#FF909090" />

    </LinearLayout>

    <LinearLayout
        android:id="@+id/passengerDetails"
        android:layout_below="@+id/tittleLayout"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:orientation="vertical">

        <Spinner …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-scrollview

0
推荐指数
1
解决办法
9126
查看次数

Android Scrollview不会填充父级空间

我有一个相对布局填满整个屏幕.我想在它的中间添加一个scrollview来包装一堆内容,这样我就可以在显示软键盘时使其平移.但是,只要我将其包装在滚动视图中,最底部的布局就会停止填充屏幕的其余部分.

这是我ScrollView注释掉的XML .

<include
    android:id="@+id/top_bar_with_save_button"
    layout="@layout/top_bar_with_save_button"/>

<FrameLayout
    android:id="@+id/log_entry_title_frame"
    android:layout_below="@id/top_bar_with_save_button"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/log_entry_title_frame"
    android:layout_alignParentBottom="true">

<!--
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">
-->

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/log_entry_title_frame"
            android:orientation="vertical"
            android:background="#f00">

            <!-- Lots of stuff in here -->
            <EditText
                android:id="@+id/log_entry_notes"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:padding="8dp"
                android:gravity="top|left"/>

        </RelativeLayout>

<!--
    </ScrollView>
 -->
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

它看起来像这样:

在此输入图像描述

但是一旦我删除它的评论ScrollView立即压缩如下:

在此输入图像描述

为什么会这样?我需要它来填充屏幕上的整个空间,我无法弄清楚发生了什么.谁能告诉我如何解决这个问题?谢谢!

android android-layout android-scrollview

0
推荐指数
1
解决办法
552
查看次数

ScrollView不能完全滚动底部

在您将其标记为重复之前,让我告诉您,我已经搜索了所有答案,但都是徒劳的。

我使用TabsActionbar

我已经设置android:layout_height="match_parent"ScrollView,如许多解决方案建议。

我还android:layout_gravity="center"按照以下建议从所有布局中删除了: Android scrollview隐藏布局中的顶部内容

我也定了,android:fillViewport="true"但是没有运气。

我还缺少其他任何技巧吗?

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">
<LinearLayout
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <CalendarView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/calendarView" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="Guest"/>

        <NumberPicker
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

        </NumberPicker>

    </LinearLayout>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/title_time_slot"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/title_add_on"/>

    <Button
        android:id="@+id/btn_confirm"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/title_btn_confirm"/>
</LinearLayout>

</ScrollView>
Run Code Online (Sandbox Code Playgroud)

这是活动的xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.squincy.wspace.ui.HomeActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar" …
Run Code Online (Sandbox Code Playgroud)

android android-scrollview

0
推荐指数
1
解决办法
1488
查看次数

如何确定NestedScrollView是否滚动到最后并且是空闲的?

试过:

NestedScrollView ns =(NestedScrollView) findViewById(R.id.nested_scroll);
        ns.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
            @Override
            public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {

            }
        });
Run Code Online (Sandbox Code Playgroud)

但是卡住了,有没有人有想法?

只是为了清除我想要的东西 - 我希望能够观察滚动状态(如在RecyclerView的addOnScrollListener中)并且只在滚动结束(空闲)时检查一次,如果用户滚动到NestedScrollView的末尾.

android scrollview android-scrollview nestedscrollview android-nestedscrollview

0
推荐指数
2
解决办法
6258
查看次数

ScrollView慢速滚动且项目消失

我正在尝试添加ScrollView来保存标头和RecyclerView。

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    <RelativeLayout
        android:id="@+id/profile"
        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="100dp"
        android:background="?attr/colorPrimary">

        <ImageView
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:id="@+id/imageView"
            android:adjustViewBounds="true"
            android:cropToPadding="false" />


    </RelativeLayout>


    <ProgressBar
        android:id="@+id/progressBar1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true" />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentStart="true"
        android:scrollbars="none"
        android:layout_alignParentLeft="true" />


    </RelativeLayout>

</ScrollView>
Run Code Online (Sandbox Code Playgroud)

但是我有两个问题尝试这样做:

  • 相对布局ID /配置文件正在消失。当我打开活动时,它会显示1秒钟,然后消失。

  • RecyclerView滚动太慢。

有任何想法吗?

android android-layout android-xml android-scrollview android-recyclerview

0
推荐指数
1
解决办法
885
查看次数