标签: android-scrollview

如何更改滚动条的宽度/厚度?

目前这是我的scrollbar.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <gradient
        android:angle="45"
        android:centerColor="@color/blue"
        android:endColor="@color/blue"
        android:startColor="@color/blue" />

    <corners android:radius="8dp" />

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

这是我的ScrollView:

<ScrollView
    android:id="@+id/scrollView1"
    android:scrollbarThumbVertical="@drawable/scrollbar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/btnBack" >
Run Code Online (Sandbox Code Playgroud)

这是它给我的滚动条.它很好,除了太厚和明显.它在这个截图中可能看起来不是很厚,但它确实如此.

在此输入图像描述

我可以设置ScrollView属性来调整滚动条的宽度/粗细吗?或者我可以在渐变中放置属性吗?

android scrollbar android-scrollbar android-scrollview

29
推荐指数
2
解决办法
3万
查看次数

动态高度viewpager

我正在尝试在自定义滚动视图中创建自定义viewpager,动态包装当前子项的高度.

package com.example.vihaan.dynamicviewpager;

import android.content.Context;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.widget.ScrollView;

    /**
     * Created by vihaan on 1/9/15.
     */
    public class CustomScrollView extends ScrollView {

        private GestureDetector mGestureDetector;

        public CustomScrollView(Context context, AttributeSet attrs) {
            super(context, attrs);
            mGestureDetector = new GestureDetector(context, new YScrollDetector());
            setFadingEdgeLength(0);
        }

        @Override
        public boolean onInterceptTouchEvent(MotionEvent ev) {
            return super.onInterceptTouchEvent(ev)
                    && mGestureDetector.onTouchEvent(ev);
        }

        // Return false if we're scrolling in the x direction
        class YScrollDetector extends GestureDetector.SimpleOnGestureListener {
            @Override
            public boolean onScroll(MotionEvent e1, MotionEvent e2,
                                    float …
Run Code Online (Sandbox Code Playgroud)

android android-custom-view android-scrollview android-viewpager

28
推荐指数
3
解决办法
2万
查看次数

Android:ScrollView中的RelativeLayout

我有一个RelativeLayout多个ImageViews,当我转过屏幕时,ImageViews变得混乱.所以我决定把它包装成一个ScrollView.但是ScrollView不起作用!

任何人都可以帮助我吗?我知道正确的方法是设计一个GridView或者ListView,但由于我有一些问题,没有人回答我,我决定这样做.

这是我的xml代码:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ScrollView01"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:scrollbars="none" >

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <Button
        android:id="@+id/continuePizza"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:text="continue" />

    <Button
        android:id="@+id/finishP"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/continuePizza"
        android:layout_alignParentLeft="true"
        android:text="finish" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="16dp"
        android:src="@drawable/download" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/imageView1"
        android:layout_marginLeft="18dp"
        android:layout_toRightOf="@+id/imageView1"
        android:src="@drawable/download" />

    <ImageView
        android:id="@+id/imageView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageView1"
        android:layout_marginTop="18dp"
        android:src="@drawable/download" />

    <ImageView
        android:id="@+id/imageView5"
        android:layout_width="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-scrollview android-relativelayout

27
推荐指数
2
解决办法
5万
查看次数

如何在代码中使用picasso设置背景图像

我知道毕加索将图像加载到imageview等,但如何使用毕加索设置我的布局背景图像?

我的代码:

public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.relativelayout);
        relativeLayout.setBackgroundResource(R.drawable.table_background);
        Picasso.with(MainActivity.this)
                .load(R.drawable.table_background)
                .resize(200, 200)
                .into(relativeLayout);
        return relativeLayout;
    }
Run Code Online (Sandbox Code Playgroud)

我在这里给出了任何错误,说它无法解决.我有一个ScrollView和相对布局.

java android android-scrollview picasso android-relativelayout

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

NestedScrollView内的子节点不能覆盖屏幕的全高

我在我的片段中使用NestedScrollView.在我的xml里面的RelativeLayout但它没有覆盖整个屏幕高度.

以下是我的代码 -

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:fitsSystemWindows="true"
android:background="@color/black"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
    android:background="@color/red_error_color"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)

在运行代码时,只有黑色背景可见但不是红色,因为我的子视图背景为红色.

提前致谢

android android-scrollview android-relativelayout android-nestedscrollview

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

ScrollView根本不滚动

我无法正确滚动ScrollView.它总是切断底部的内容,就像它是正常的LinearLayout一样.

我的代码

<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:id="@+id/scroll_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:isScrollContainer="true"
        android:orientation="vertical" >
Run Code Online (Sandbox Code Playgroud)

当然,我已经尝试添加/删除"fillViewport"和"isScrollContainer"属性,它根本没有改变任何东西.

提前致谢.

android scroll android-linearlayout android-scrollview

24
推荐指数
3
解决办法
4万
查看次数

Android scrollview onScrollChanged

我在滚动视图中的文本视图中有一个固定的内容.当用户滚动到某个位置时,我想开始一个活动或触发一个Toast.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent" android:layout_height="fill_parent"
 android:id="@+id/scroller">
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical" android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <TextView android:layout_width="fill_parent" android:id="@+id/story"
   android:layout_height="wrap_content" android:text="@string/lorem"
   android:gravity="fill" />
 </LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

我的问题是实现受保护的方法onScrollChanged来找出滚动视图的位置.

我找到了这个答案,是否有一个更简单的解决方案,而不是声明一个界面,覆盖滚动视图等,如我发布的链接上所示?

android android-scrollview onscrollchanged

23
推荐指数
4
解决办法
7万
查看次数

android RelativeLayout以编程方式更改高度

我尝试以编程方式更改布局高度.我有两个按钮.在一个按钮中我改变了我的布局位置和第二个按钮我尝试接收保存位置,这是我第一次.

<RelativeLayout
    android:id="@+id/popaplayout"
    android:layout_width="fill_parent"
    android:layout_height="200dp" >
Run Code Online (Sandbox Code Playgroud)

这是我的布局和我写的第一个按钮

RelativeLayout.LayoutParams parms = new RelativeLayout.LayoutParams(
                    RelativeLayout.LayoutParams.FILL_PARENT,
                    RelativeLayout.LayoutParams.FILL_PARENT);
parms.addRule(RelativeLayout.BELOW, R.id.movies_title_layout);
scrollpopap.setLayoutParams(parms);
scrollpopap.setScrollingEnabled(true);
Run Code Online (Sandbox Code Playgroud)

和第二个按钮

RelativeLayout.LayoutParams rel_btn = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, 300);
rel_btn.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
scrollpopap.setLayoutParams(rel_btn);
scrollpopap.setScrollingEnabled(false);
Run Code Online (Sandbox Code Playgroud)

xml文件中我写了高度200dp和编程300,并有不同的高度.我怎样才能以编程方式编写保存高度?

如果有人知道解决方案,请帮助我谢谢

android android-scrollview android-relativelayout

23
推荐指数
4
解决办法
5万
查看次数

GridView有两列,第一项跨越两列

我有一个Imageview和一个gridview ..

我的布局设计在这里..

在此输入图像描述

我想将这两个视图合并到单个gridview中

我的问题:

如何在两列中设置gridview第一个项目跨度?

android android-scrollview

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

在Android中创建锁定的ScrollView

我正在尝试ScrollView在Android中实现一个在当前滚动位置上方添加项目时不滚动的内容.

默认实现的ScrollView行为如下:

在当前滚动位置上方添加项目: 在此输入图像描述

在当前滚动位置下方添加项目: 在此输入图像描述

如何ScrollView在当前滚动位置上方添加项目之前"锁定" ?

这是我的布局文件,我目前已经覆盖了ScrollViewLinearLayout,但尚未做出任何改动.

<LinearLayout
      android:layout_height="fill_parent"
      android:orientation="vertical"
      android:layout_width="fill_parent">

    <LinearLayout
        android:id="@+id/LinearLayout02"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_alignParentBottom="true">
        <Button
            android:id="@+id/Button02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1" android:text="Add To Top"
            android:onClick="addToStart">
        </Button>
        <Button
            android:id="@+id/Button03"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Add to End"
            android:onClick="addToEnd">
        </Button>
    </LinearLayout>
    <com.poc.scroller.locable.lockablescrollerpoc.LockedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fillViewport="true"
        android:scrollbarAlwaysDrawVerticalTrack="true"
        android:verticalScrollbarPosition="right"
        android:fadeScrollbars="false"
        android:background="@color/scrollColor">

        <com.poc.scroller.locable.lockablescrollerpoc.LockedLinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:id="@+id/Container">
        </com.poc.scroller.locable.lockablescrollerpoc.LockedLinearLayout>

    </com.poc.scroller.locable.lockablescrollerpoc.LockedScrollView>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

源代码示例: https ://github.com/Amaros90/android-lockable-scroller-poc

谢谢!

android android-scrollview

22
推荐指数
2
解决办法
837
查看次数