这似乎是一个有很多答案的问题; 但是,我找不到一个通用的方法.我正试图在ListView达到底部时添加数据; 使用数据从Internet检索数据AsyncTask.ListView已经有一个适配器连接到它.
因此,为了找到实现这一目标的好方法,我得出了两种不同的方法.
onScrollStateChanged()方法,该方法基本上与此页面相关.但是,它使用的参数在实际API中没有对应关系.同时,此链接使用正确的API,但我不知道是否以正确的方式.我尝试了两个链接中的第一个,但它有点像meh.调试应用程序,diff值变化很大,我不知道如何正确地插入表达式.另外,我不知道如何修复我可以开始检索数据的偏移量; 我的意思是,我想执行代码而不是在我即将到达底部时,而是在我到达之前.此外,即使我们滚动到顶部,有时它也会被调用.onScroll()方法,在本答案中使用,或者以不同的方式在此代码中使用.我尝试调整两个代码中的最后一个,但它会导致很多问题,即使我们没有到达列表的底部,也会加载数据.那么,最好的方法是什么?何时以及为什么我更喜欢其中一个?在我的情况下,我应该使用哪两个?
如果太大,是否有可能使Android ActionBar的标题自动滚动(选取框)?
我在DrawerLayout的结束面板中有一个SeekBar
问题是我们无法在不关闭右侧面板的情况下滑动Seekbar.
如果试图通过覆盖onTouchEvent方法和DrawerLayout的closeDrawer而没有成功来玩
我的编辑文字:
android:scrollbars="horizontal|vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:inputType="textMultiLine|textNoSuggestions"
android:ems="10"
android:gravity="top|left"
Run Code Online (Sandbox Code Playgroud)
我的代码:
myet = (EditText) findViewById(R.id.myedittext);
myet.setScrollbarFadingEnabled(true);
myet.setHorizontallyScrolling(true);
Run Code Online (Sandbox Code Playgroud)
由于一些奇怪的原因,它会滚动,但滚动条本身不会移动,它会粘在edittext的左下角.
我想这与edittext没有静态宽度有关.
如何修复水平滚动条使其可以移动,其大小与最长行成比例.
注意:它必须是多行的,并且还要垂直滚动.
我正在使用moondroid Coverflow,并且我的代码工作正常.现在我希望项目在到达其结束位置时停止滚动.目前滚动没有尽头.任何人都可以帮我解决.还想知道Coverflow中是否有任何默认方法来执行上述活动.
private void setCoverFlowMapView(List<PropertyRS> proReplica, Integer posMarker) {
//moondroid coverflow 2826
mData = (ArrayList<PropertyRS>) proReplica;
mCoverFlow = (FeatureCoverFlow) rootView.findViewById(R.id.coverflow);
mAdapter = new CoverFlowAdapter(getActivity(), this,posMarker);
mAdapter.setData(mData);
mCoverFlow.setAdapter(mAdapter);
mCoverFlow.computeScroll();
if (posMarker != null) {
mCoverFlow.scrollToPosition(posMarker);
}
mCoverFlow.setOnScrollPositionListener(new FeatureCoverFlow.OnScrollPositionListener() {
@Override
public void onScrolledToPosition(int position) {
Double cvLat = mData.get(position).latitude;
Double cvLong = mData.get(position).longitude;
System.out.println("coverflow item position " + position);
mAdapter.setPos(position);
((BaseAdapter)mCoverFlow.getAdapter()).notifyDataSetChanged();
LatLng cvLatLng = new LatLng(cvLat, cvLong);
CameraUpdate cvCameraUpdate = CameraUpdateFactory.newLatLngZoom(cvLatLng, 15);
googleMap.animateCamera(cvCameraUpdate);
}
@Override
public void onScrolling() {
}
}); …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Recyclerviews 在 android 中创建一个 EPG。它需要固定的顶行水平滚动显示与时间相对应的节目,固定最左列垂直滚动显示各种频道。
基于这个SO 答案,我带来了以下内容
<?xml version="1.0" encoding="utf-8"?>
<!--Outer container layout-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".MainActivity">
<!--To display Channels list-->
<LinearLayout
android:layout_width="150dp"
android:layout_height="match_parent"
android:orientation="vertical">
<!--Position (0,0)-->
<TextView
android:id="@+id/tv_change_date"
android:layout_width="match_parent"
android:layout_height="50dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rcv_channel_name"
android:scrollbars="none"
android:layout_width="150dp"
android:layout_height="match_parent"/>
</LinearLayout>
<!--To display Time and Programs list-->
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<!--Time horizontal list-->
<android.support.v7.widget.RecyclerView
android:id="@+id/rcv_vertical_header"
android:scrollbars="none"
android:layout_width="match_parent"
android:layout_height="50dp"/>
<!--Vertical list whose each element is horizontal list to show programs-->
<android.support.v7.widget.RecyclerView
android:id="@+id/rcv_vertical"
android:scrollbars="vertical"
android:layout_width="match_parent" …Run Code Online (Sandbox Code Playgroud) 我使用AChartEngine Api创建了动态折线图,显示了G-Force值的变化.一切正常,但当图形在X轴向前移动时,我必须在X轴上手动滚动才能进一步查看,如果您没有正确使用我,请查看下面的图像.
如何让它在x轴上自动滚动以避免手动滚动?
以下是我的代码
public class GraphActivity extends Activity implements SensorEventListener{
private LinearLayout lyGforce;
//=== G-force =======
private SensorManager mSensorManager;
private Sensor mAccelerometer;
private float gOffset;
private boolean calibrate;
private static TimeSeries timeSeriesGforce;
private static XYMultipleSeriesDataset datasetGforce;
private static XYMultipleSeriesRenderer rendererGforce;
private static XYSeriesRenderer rendererSeriesGforce;
private static GraphicalView viewGforce;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.mainactivity);
lyGforce = (LinearLayout) findViewById(R.id.lygforce);
//=========== G-force =======
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); …Run Code Online (Sandbox Code Playgroud) 您如何显示一侧(水平/垂直)非常大的项目列表,并允许它自由滚动/拖动 - 就像 Google 表格一样?
我试过使用 aNestedScrollView和 a RecyclerView,但一次只能向一个方向滚动,我需要它能够自由拖动(不需要捏/缩放功能,但如果可以做到,它是一个奖金)。
这是我尝试过的 GIF,它有效,但绝对不是我想要的。
这是布局文件:
<?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">
<include
layout="@layout/include_toolbar"
android:id="@+id/toolbar" />
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_biscroll"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) android android-scrollview android-scroll android-recyclerview android-scrolling
我有一个Fragment,有一个ScrollView在Fragment。
<ScrollView
android:id="@+id/scroll_view"
android:layout_width="0dp"
android:layout_height="0dp"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appbar">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.tatar.mobile.widget.CardSelectionView
android:id="@+id/card_selection_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:accountRightTextView1="@string/available"
app:accountTitleTextView="@string/from"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/line_text_view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:background="@color/gray.light"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/card_selection_view" />
<Spinner
android:id="@+id/type_spinner"
style="@style/spinner"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/line_text_view" />
<Spinner
android:id="@+id/company_spinner"
style="@style/spinner"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/type_spinner" />
<LinearLayout
android:id="@+id/dynamic_form_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/company_spinner" />
<Spinner
android:id="@+id/installment_spinner"
style="@style/spinner"
android:layout_marginTop="8dp"
android:visibility="invisible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/dynamic_form_container" />
<Button
android:id="@+id/continue_button"
style="@style/action_button"
android:layout_marginTop="16dp" …Run Code Online (Sandbox Code Playgroud) android android-softkeyboard android-fragments android-scrollview android-scroll
我有一个添加购物清单项目 Jetpack Compose 屏幕,其中包含多个TextField输入和底部的图像容器。屏幕在底部溢出并被切断。我怎样才能滚动屏幕?
android android-orientation android-scroll android-jetpack-compose