标签: android-scrollview

如何在滚动视图下方添加空间

我将活动包装在scroll view下面的类似文件中。

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    >

    <include layout="@layout/content_form" />

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

我在content_form布局中大约有15个字段,问题是布局中的最后一项content_form附有底部。

我需要在滚动视图下方添加一个边距,我已经尝试给scrollviewcontent_form字段和最后一个字段赋予边距,但是没有任何作用。

使用时,我需要知道如何在页面底部添加边距scroll view

android android-layout android-scrollview

2
推荐指数
4
解决办法
1541
查看次数

如何禁用 React Native Scrollview/Flatlist 上的拉伸效果?

这就是我所描述的效果。我正在 android studio 上使用 API 32 的 Pixel 3 进行模拟。该页面是一个没有样式的滚动视图,以及一堆带有颜色样式和高度和宽度设置的视图。

在此输入图像描述

android-scrollview reactjs react-native

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

在刷新时禁用listview中的滚动

问题是我对列表进行了一些更改,而且总是滚动到顶部.我知道我可以滚动到底部但这不是我想要的.我想禁用滚动,我的意思是当我对列表进行更改时我希望保持在那里我不想滚动到顶部.我只是希望我的滚动不要改变(只是为了保持在同一个地方)我尝试这样做以将列表的转录模式设置为禁用,但它仍然在更改后列表转到顶部.

lv.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_DISABLED);
Run Code Online (Sandbox Code Playgroud)

android listview scroll android-layout android-scrollview

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

如何在ScrollView中滑动垂直SeekBar

我通过覆盖onDraw方法并将其翻转90度来制作垂直SeekBar.现在我需要将它放在ScrollView中.

实际的布局结构是

<ScrollView>
  <RelativeLayout>
     ...
     <LinearLayout>
       <com.mypackage.VerticalSeekBar/>
Run Code Online (Sandbox Code Playgroud)

是否可以确保ScrollView无法获取我的搜索栏的触摸事件?

android android-layout android-scrollview android-event

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

在ScrollView中滚动ListView

我有一个ScrollView.它的一个孩子是ListView.两者都朝同一方向滚动.如何让它们都响应滚动事件?然后当到达ListView的末尾时,事件转到父ScrollView,以便ScrollView可以滚动?

xml布局:

<?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"
    >

    <LinearLayout
        ...
        android:orientation="vertical"
        >



        <LinearLayout
            android:id="@+id/..."
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0"

            android:orientation="horizontal">

            ...
        </LinearLayout>

        <android.support.v4.view.ViewPager
            .../>


        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="@dimen/pad_half"
            >
        </RelativeLayout>

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



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

我的ListView实际上进入了ViewPager.该设计使得ListView中的大约三个项目可见,并且用户能够滚动以查看其他项目.与此同时,ViewPager上方和下方的视图都是可见的.同样,它是一个ViewPager:它有其他页面而不是ListView.

android android-layout android-listview android-scrollview

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

ScrollView滚动,但不会完全显示其内容

我使用此代码将我的布局划分为2个滚动视图

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

<RelativeLayout

    android:layout_width="match_parent"
    android:layout_height="0px"
    android:background="@drawable/ashokb"
    android:layout_weight="4" >
<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true" 
    android:background="@drawable/flagc">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" 
        android:layout_gravity="center">

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

        <TextView
            android:id="@+id/textView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#000000" />

        <Button
            android:id="@+id/button1"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_marginLeft="-50dp"
            android:background="@drawable/ic_menu_share" />

    </LinearLayout>

    <TextView
            android:id="@+id/textView5"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Medium Text"
            android:textColor="#000000" 

            android:gravity="center"
            android:textAppearance="?android:attr/textAppearanceMedium" />

  </LinearLayout>
</ScrollView>
</RelativeLayout>

<RelativeLayout

    android:layout_width="match_parent"
    android:layout_height="0px"
    android:background="@drawable/ashokb"
    android:layout_weight="1" >

    <ScrollView
        android:id="@+id/scrollView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" > …
Run Code Online (Sandbox Code Playgroud)

android textview android-layout android-linearlayout android-scrollview

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

Android:ImageTIew onTouch Drag被ScrollView ontouch Event拦截

我正在使用scrollview中的imageview控制器.在实现和测试方面,我发现滚动总是覆盖onTouch事件而不是imageView(dragImage).

我尝试使用它来启用滚动

scv.setOnTouchListener(null);    
Run Code Online (Sandbox Code Playgroud)

这要禁用

scv.setOnTouchListener( new OnTouchListener(){ 
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        return true; 
    }
});
Run Code Online (Sandbox Code Playgroud)

它显示了hatImage只拖动了一个非常小的动作而不是在我想要的地方拖动.当我触摸ImageView而不是scrollView时,你能告诉我禁用滚动的更好方法吗?

以下是我的工作:

public static class PlaceholderFragment extends Fragment   {



private static final String ARG_SECTION_NUMBER = "section_number";

    /**
     * Returns a new instance of this fragment for the given section number.
     */
    public static PlaceholderFragment newInstance(int sectionNumber) {
        PlaceholderFragment fragment = new PlaceholderFragment();
        Bundle args = new Bundle();
        args.putInt(ARG_SECTION_NUMBER, sectionNumber);
        fragment.setArguments(args);            
        return fragment;
    }




    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle …
Run Code Online (Sandbox Code Playgroud)

android ontouchlistener android-imageview android-scrollview

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

Android - ScrollView和PercentRelativeLayout

将android.support.percent.PercentRelativeLayout与ScrollView结合使用时遇到问题.以下xml文件

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:scrollbars="none">

<android.support.percent.PercentRelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:background="@color/white"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    >
    <ImageView
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        app:layout_widthPercent="50%"
        app:layout_heightPercent="50%"
        app:layout_marginTopPercent="5%"
        app:layout_marginLeftPercent="5%"
        android:src="@drawable/o"
        android:id="@+id/imageView3" />
    <ImageView
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        app:layout_widthPercent="50%"
        app:layout_heightPercent="50%"
        app:layout_marginTopPercent="30%"
        app:layout_marginLeftPercent="5%"
        android:src="@drawable/o"
        android:layout_below="@+id/imageView3"
        android:layout_alignStart="@+id/imageView3"
        android:layout_marginTop="151dp" />
</android.support.percent.PercentRelativeLayout>
Run Code Online (Sandbox Code Playgroud)

打印这个 不是我想要的

使用RelativeLayout它工作正常.有谁知道问题出在哪里?谢谢!

编辑:如果我将ScrollView高度设置为1000dp它也工作正常,但我希望高度像元素一样高

android android-scrollview android-relativelayout android-percentrelativelayout

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

如何在Android中以编程方式将ScrollView滚动到底部?

如何在Android中以编程方式将ScrollView滚动到底部?

建议的代码

logScroll.scrollTo(0, logScroll.getBottom());
Run Code Online (Sandbox Code Playgroud)

不起作用(滚动到开头的底部,而不是实际的底部).

布局如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.inthemoon.trylocationlistener.MainActivity">

    <ScrollView
        android:id="@+id/log_scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:id="@+id/log_text"

            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </ScrollView>


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

填充代码如下:

@BindView(R.id.log_scroll)
    ScrollView logScroll;

    @BindView(R.id.log_text)
    TextView logText;

    private void log(String msg) {
        logText.append(new SimpleDateFormat( "HH:mm:ss ", Locale.US ).format(new Date()) + msg + "\n");
        logScroll.scrollTo(0, logScroll.getBottom());
    }
Run Code Online (Sandbox Code Playgroud)

UPDATE

我读了一些答案并写道:

private void log(String msg) {
        logText.append(new SimpleDateFormat( "HH:mm:ss ", Locale.US ).format(new Date()) + msg + "\n");
        //logScroll.scrollTo(0, logScroll.getBottom());
        logScroll.fullScroll(View.FOCUS_DOWN);
    }
Run Code Online (Sandbox Code Playgroud)

为什么比使用更糟 …

android android-scrollview

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

当焦点集中在editText上时,滚动条未在“活动”中完全滚动时,如何在其顶部的状态栏进行全屏活动?

在将文本输入EditText之前的布局

在EditText中输入文本后的布局

问题是,当我在EditText中输入文本时,ScrollView无法正常工作,并且无法在活动中滚动

     fun statusBarColor(activity: Activity) {


     val window = activity.window
    // add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
    window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
   // clear FLAG_TRANSLUCENT_STATUS flag:
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
 //window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);            
    // finally change the color
    //window.statusBarColor = ContextCompat.getColor(activity, R.color.colorPrimaryDark)
    //window.setStatusBarColor(Color.TRANSPARENT);

}
      //Manifest code on activity.
       android:windowSoftInputMode="adjustResize">
Run Code Online (Sandbox Code Playgroud)

android android-layout android-scrollview kotlin

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