我想启用ScrollView并通过按钮单击禁用它.
禁用意味着如果ScrollView不在那里..并启用它返回ScrollView.
我想要的是因为我有一个带有文本图像的图库,并且在按钮上单击屏幕方向更改,因此在横向文本中文本会变大.我想要ScrollView,因此图像不会伸展自身,文本变得不可读.
scrollview.Enabled=false / setVisibility(false) 没有做任何事情.
XML:
<ScrollView
android:id="@+id/QuranGalleryScrollView"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<Gallery android:id="@+id/Gallery"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="horizontal"></Gallery>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
谢谢
Edit1:我不能使用Visibility(消失),因为那也会隐藏Gallery,我想要的是隐藏ScrollView的效果.当有ScrollView时,Gallery中的图像变为scrollabale并且不适合屏幕,所以你必须滚动才能看到整个图像,我不想在按钮点击时禁用/启用它.
我试过这个:
((ScrollView)findViewById(R.id.QuranGalleryScrollView)).setOnTouchListener(null);
((ScrollView)findViewById(R.id.QuranGalleryScrollView)).setHorizontalScrollBarEnabled(false);
((ScrollView)findViewById(R.id.QuranGalleryScrollView)).setVerticalScrollBarEnabled(false);
((ScrollView)findViewById(R.id.QuranGalleryScrollView)).setEnabled(false);
Run Code Online (Sandbox Code Playgroud)
但是图库中的图像仍然是可滚动的,不适合屏幕..这是什么解决方案?
我有一个<ScrollView>布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_scrollview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/input_one"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="number" >
<EditText
android:id="@+id/input_two"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="number" >
<EditText
android:id="@+id/input_three"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="number" >
<Button
android:id="@+id/ok_btn"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:text="@string/ok_str" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
如上所示,简单布局包含三个输入字段和一个"确定"按钮.
我使用上面的布局运行我的应用程序,当我点击第一个输入字段(@+id/input_one)时,软键盘将从屏幕底部弹出,它隐藏第三个输入字段和"确定"按钮.
自从我使用以来<ScrollView>,我想我可以向上滚动页面以查看第三个输入字段和软键盘隐藏的"确定"按钮,但页面不可滚动.为什么?如何摆脱它?基本上,我想看到每个输入字段和"确定"按钮,甚至软键盘弹出.
android android-keypad android-intent android-layout android-scrollview
我有一个应用程序,它有一个使用的活动ScrollView.我需要检测用户何时到达底部ScrollView.我做了一些googleing,我发现这个页面在哪里解释.但是,在这个例子中,那些人扩展了ScrollView.正如我所说,我需要扩展Activity.
所以,我说"好吧,让我们尝试使自定义类扩展ScrollView,覆盖onScrollChanged()方法,检测滚动结束,并相应地采取行动".
我做了,但在这一行:
scroll = (ScrollViewExt) findViewById(R.id.scrollView1);
Run Code Online (Sandbox Code Playgroud)
它扔了一个 java.lang.ClassCastException.我<ScrollView>在XML中更改了标签,但显然它不起作用.我的问题是:为什么,如果ScrollViewExt延伸ScrollView,扔到我脸上ClassCastException?有没有办法检测滚动结束而不会搞得太多?
谢谢大家
编辑:正如所承诺的,这是我的XML重要部分:
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<WebView
android:id="@+id/textterms"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:textColor="@android:color/black" />
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
我改变了它从TextView到WebView到能证明里面的文字.我想要实现的是"在完全阅读合同条款之前,接受按钮不会激活"的事情.我的扩展类称为ScrollViewExt.如果我更改标签ScrollView,ScrollViewExt它会抛出一个
android.view.InflateException: Binary XML file line #44: Error inflating class ScrollViewExt
Run Code Online (Sandbox Code Playgroud)
因为它不懂标签ScrollViewEx.我不认为它有解决方案......
谢谢你的回答!
我有多个LinearLayouts,其组合高度很容易超过设备的屏幕高度.所以为了使我的布局可滚动,我尝试添加一个ScrollView,但不幸的是我收到以下错误:
Scrollview只能容纳一个直接孩子
我做了一些研究,但即使在阅读了几个解决方案之后,也无法理解如何解决它.我尝试了一些改变,但到目前为止我没有任何作用.有帮助吗?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="20dip">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Question 1"
android:paddingBottom="20dip"
android:gravity="center" />
<TextView
android:id="@+id/q1_score"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=""
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Question 2"
android:paddingBottom="20dip"
android:gravity="center" />
<TextView
android:id="@+id/q2_score"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=""
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Question 3"
android:paddingBottom="20dip"
android:gravity="center" />
<TextView
android:id="@+id/q3_score"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=""
android:gravity="center"/>
</LinearLayout> …Run Code Online (Sandbox Code Playgroud) 我正在使用TableLayout.我需要为此布局同时进行水平和垂直滚动.默认情况下,我可以在视图中进行垂直滚动,但水平滚动不起作用.
我使用的是Android SDK 1.5 r3.我已经尝试过了android:scrollbars="horizontal".
我在一些论坛上看到,在杯形蛋糕更新中,水平滚动是可能的.
如何让我的布局在两个方向上滚动?
我正在尝试使用CoordinatorLayout关注Google文档,但我在CoordinatorLayout中遇到了ScrollView的问题.基本上,当向下滚动时,工具栏通常会使用RecyclerView或Listview折叠.现在使用ScrollView它不会崩溃.
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<TextView
android:id="@+id/tv_View"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/filler"
style="@style/TextAppearance.AppCompat.Large"
/>
</ScrollView>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud) android toolbar android-scrollview android-toolbar coordinator-layout
我有一个RecyclerView.每行都有一个播放按钮,textview和Progressbar.单击播放按钮时必须播放我的SD卡中的音频并且必须进度Progressbar问题是当我向下滚动recyclerview时,请更改下一行中的Progressbar.意思是我可以同时在屏幕上显示5个项目.当我滚动到第6行,第6行搜索栏突然改变.
public class ListAdapter extends RecyclerView.Adapter {
private List<Historyitem> stethitems;
public Context mContext;
public Activity activity;
public Handler mHandler;
static MediaPlayer mPlayer;
static Timer mTimer;
public ListAdapter(Activity activity,Context mContext,List<Historyitem> stethitems) {
this.stethitems = stethitems;
this.mContext = mContext;
this.activity = activity;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View rootView = LayoutInflater.
from(mContext).inflate(R.layout.stethoscopeadapteritem, null, false);
RecyclerView.LayoutParams lp = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
rootView.setLayoutParams(lp);
mHandler = new Handler();
return new MyViewHolder(rootView);
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, int position) { …Run Code Online (Sandbox Code Playgroud) 我有一个带ScrollView的应用程序,我不希望滚动条出现在屏幕上.如何在确保滚动仍然有效的同时隐藏ScrollView中的滚动条?
我有一个奇怪的问题,我不知道如何解决.我在ScrollView中有一个RelativeLayout,这个scrollView的高度设置为fill_parent.RelativeLayout也是如此.尽管如此,内容并没有填满整个屏幕,它只会进入此RelativeLayout中最后一个布局的wrap_content.
这是我的代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.pontai"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/relativeLayout3"
android:layout_alignParentTop="true"
android:layout_alignRight="@+id/relativeLayout5"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="How much points you have here:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/textViewTotalPoints1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="120"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<RelativeLayout
android:id="@+id/relativeLayout4"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_alignLeft="@+id/relativeLayout3"
android:layout_below="@+id/linearLayout1"
android:layout_marginTop="5dp"
android:layout_toLeftOf="@+id/textView7"
android:orientation="vertical" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:text="Ratings"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textViewPositivePoints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="25dp" …Run Code Online (Sandbox Code Playgroud) android android-layout android-scrollview android-relativelayout
我用了一个布局的滚动型,并在尝试使用新的CoordinatorLayout从设计支持库.
我的布局文件如下所示:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
...
</LinearLayout>
</ScrollView>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar ... />
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
测试时,scrollview仅占用屏幕的一部分.什么地方出了错?
android android-scrollview android-support-library material-design android-design-library