标签: android-scrollview

如何以编程方式将ScrollView滚动到底部

我有一个问题我无法解决:在ScrollView中我只有一个LinearLayout.通过用户操作,我以编程方式在此LinearLayout上添加2个TextView,但默认情况下,滚动保持在顶部.由于我控制用户操作,我应该很容易滚动到底部,例如:

ScrollView scroll = (ScrollView) this.findViewById(R.id.scroll);
scroll.scrollTo(0, scroll.getBottom());
Run Code Online (Sandbox Code Playgroud)

但事实并非如此.因为在添加这两个新元素后立即getBottom()仍然返回前两个.我试图刷新状态调用refreshDrawableState(),但我不工作.

你知道如何在添加一些元素后获得ScrollView的实际底部吗?

java android android-layout android-scrollview

43
推荐指数
4
解决办法
6万
查看次数

Android:ScrollView不会滚动键盘输出

我有一些带有一些视图的布局,其中一个是EditText.布局很容易适合一页,但是当软键盘输出时,布局不会滚动.这是我的布局的概述:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background" >

    <ScrollView
        android:id="@+id/ScrollView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true" >

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

            <CheckBox/>

            <TextView/>

            <LinearLayout>
                <EditText>
                    <requestFocus />
                </EditText>
            </LinearLayout>

            <TextView/>

            <LinearLayout>
                <Spinner/>
            </LinearLayout>

        </LinearLayout>

    </ScrollView>

    <Button
        android:layout_alignParentBottom="true" />

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

在我的清单中,我已经声明了属性:

android:windowSoftInputMode="adjustResize|stateHidden"
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么它不起作用以及如何确保它确实有效?

提前致谢!

java android android-layout android-softkeyboard android-scrollview

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

EditText在ScrollView中不可滚动

我有一个ScrollView内部,EditText它被设置为垂直滚动.但它不会滚动.相反,整个布局滚动,每当我尝试滚动EditText.以下是代码 -

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout 
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<TextView
    android:id="@+id/b1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="39dp"
    android:text="Title"
    android:textColor="#3bb9ff"
    android:textSize="15sp" />

<EditText
    android:id="@+id/Text1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:hint="Title"
    android:singleLine="true" >

    <requestFocus />

</EditText>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Content"
    android:layout_marginTop="50dp"
    android:textColor="#3bb9ff"
    android:textSize="15sp"
   />


<EditText
    android:id="@+id/newTodoText"
    android:layout_width="fill_parent"
    android:layout_height="match_parent" 
    android:minLines="2"
    android:maxLines="7"
     android:hint="Write something"
     android:scrollbars = "vertical" >
</EditText>
<Button
    android:id="@+id/Add"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="Add" />


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

ID为"newTodoText"的EditText在这里有问题.

android android-layout android-edittext android-scrollview android-view

42
推荐指数
6
解决办法
3万
查看次数

Android键盘隐藏了EditText

当我尝试在屏幕底部的EditText中写入内容时,软键盘会隐藏EditText.我该如何解决这个问题?下面是我的xml代码.我在片段中使用它.

<ScrollView 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="fill_parent"
        android:layout_height="wrap_content" >


        <LinearLayout
            android:id="@+id/linearLayoutTopDetails"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/linearLayoutTop"
            android:layout_marginLeft="6dp"
            android:layout_marginRight="6dp"
            android:layout_marginTop="6dp"
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/list_design1"
                android:orientation="vertical" >

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="80dp"
                    android:layout_weight="100"
                    android:orientation="horizontal" >

                    <ImageView
                        android:id="@+id/ImageViewProfImagePostDetail"
                        android:layout_width="0dp"
                        android:layout_height="fill_parent"
                        android:layout_marginTop="2dp"
                        android:layout_weight="24.84"
                        android:paddingLeft="5dp"
                        android:paddingRight="5dp"
                        android:paddingTop="5dp" />

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="60"
                        android:orientation="vertical" >

                        <TextView
                            android:id="@+id/textViewNamePostDetail"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Robin"
                            android:textSize="17sp" />

                        <TextView
                            android:id="@+id/textViewLocationPostDetail"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="1dp"
                            android:drawableLeft="@drawable/location"
                            android:text="beijing, China" />

                        <TextView
                            android:id="@+id/textViewTimeAgoPostDetail"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text=" 18min ago" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="fill_parent"
                        android:layout_weight="15"
                        android:orientation="horizontal" > …
Run Code Online (Sandbox Code Playgroud)

android android-keypad android-layout android-edittext android-scrollview

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

ScrollView和ListView之间的区别

任何人都可以解释滚动视图和列表视图之间的区别吗?什么时候使用哪一个?哪一个更有效率?

android android-listview android-scrollview

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

Android scrollview隐藏布局中的顶级内容

我有一个问题,其中android scrollview开始隐藏我在我的布局顶部的一对textview,我发现在这个网站上有另一个人有这个问题,并能够得到帮助不幸的是,帮助他们的人实际上没有说什么修复它,谁能告诉我这里的修复是什么?

android scrollview隐藏顶级内容

任何帮助都很大这里是我的xml代码:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/title_color_dark_transparent" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_vertical|center_horizontal|center"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="5dp"
        android:orientation="vertical"
        android:paddingTop="5dp" >

        <TextView
            android:id="@+id/saysomething"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/loading"
            android:textColor="#FFFFFF"
            android:textSize="30dp" />

        <TextView
            android:id="@+id/saysomethinginfo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:text="@string/loading"
            android:textColor="#FFFFFF"
            android:textSize="17dp" />

        <EditText
            android:id="@+id/tweetedittext"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/edit_text"
            android:gravity="top"
            android:hint="@string/edittext_hint"
            android:inputType="textCapSentences|textMultiLine|textAutoCorrect|textAutoComplete"
            android:lines="3"
            android:textAppearance="@style/TextAppearance.EditText"
            android:textSize="17dp" />

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginTop="5dp"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/photobutton"
                style="@style/TextAppearance.Button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/button_background"
                android:onClick="photobuttonClicked"
                android:text="@string/photobuttontext"
                android:textSize="15dp" />

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

android android-layout android-xml android-scrollview

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

如何判断Android中的视图是否可见?

我要检查,如果View内的ScrollView是目前Android中可见.我没有检查它是否专注于它,但它是否正在屏幕上显示.有没有一种方法View可以告诉我视图当前是否可见?

android visible android-scrollview android-view

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

向下滚动时,RecyclerView项目之间形成较大的间隙

我正在制作ToDo列表应用程序,并且在测试时,出于某种原因,每当我尝试向下滚动时,项目之间会形成巨大的差距.每当我拖放项目时总会发生这种情况,但我没有看到我的ItemTouchHelper适配器和回调类有任何错误.如果你可以帮助我,那将是非常棒的.

之前: 之前

后: 后

RecyclerAdapter.java

public class RecyclerAdapter extends                                                                                                                                 

RecyclerView.Adapter<RecyclerAdapter.RecyclerVH> implements ItemTouchHelperAdapter{
private LayoutInflater layoutInflater;
ArrayList<Info> data;
Context context;

public RecyclerAdapter(Context context) {
    layoutInflater = LayoutInflater.from(context);
    this.context = context;
}

public void setData(ArrayList<Info> data) {
    this.data = data;
    notifyDataSetChanged();
}

@Override
public RecyclerVH onCreateViewHolder(ViewGroup viewGroup, int position) {
    View view = layoutInflater.inflate(R.layout.custom_row, viewGroup, false);
    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d("R.A onClick Owen", "onClick method triggered");
        }
    });
    RecyclerVH recyclerVH = new RecyclerVH(view);
    return recyclerVH;
}

@Override
public …
Run Code Online (Sandbox Code Playgroud)

android android-scrollview android-recyclerview

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

Android:弹出键盘上的背景图片大小调整

我正在开发一个应用程序,其中背景图像在键盘弹出窗口缩小.我的.xml如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:facebook="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background" >

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

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

            /**
              Other stuff 
            */

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

我在Google上搜索并发现,要添加

android:windowSoftInputMode="stateVisible|adjustPan"
Run Code Online (Sandbox Code Playgroud)

在我的清单文件中.但它没用.

编辑:

键盘弹出前我的布局如下:

图片1

弹出后像:

图2

请检查背景图像的差异.在图像1中,图像的大小和图像2的背景图像缩小.我需要在键盘弹出窗口向上移动页脚和背景.

我错过了什么或做错了请建议我.

android android-layout android-scrollview android-background

32
推荐指数
6
解决办法
2万
查看次数

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