我想听ScrollView看它是否滚动.我使用OnTouchListener,效果很好.但是当我想使用OnKeyListener添加与轨迹球的兼容性或重写OnKeydown方法时,它无法工作.看起来像焦点的儿童按钮导致问题.
解决此问题的任何解决方案或解决方法?任何帮助表示赞赏.
以下是一些重现我的问题的演示代码:
public class TestActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ScrollView scrollView = (ScrollView) findViewById(R.id.scroll_view);
LinearLayout mainLayout = (LinearLayout) findViewById(R.id.main_layout);
LinearLayout.LayoutParams wrapParams = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
for (int i = 0; i < 100; i++) {
MyItem item = (MyItem) LayoutInflater.from(this).inflate(R.layout.item, null);
item.setParent(scrollView);
item.setBackgroundColor(Color.WHITE);
item.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
mainLayout.addView(item, wrapParams);
}
scrollView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// can go into here
}
});
scrollView.setOnKeyListener(new OnKeyListener() {
@Override …Run Code Online (Sandbox Code Playgroud) 我有一个片段,并希望添加一个库,但我看到该画廊已被弃用.....
更具体地说,我实际上想要一个水平列表视图,因为我想自定义视图(在每一行中包含图像和文本)并允许它是srcollable.
此外,"行"的数量(如果水平它的列然后....)随数据库而变化,所以它不是静态的,我不想限制"行"的数量
谷歌帮助我找到了一些解决方案:viewpager和其他附加库
但哪一个更好?
我希望将来我不需要一直修复代码!谢谢!!!!
android android-gallery android-scrollview android-viewpager
我尝试在活动布局上的所有内容周围添加滚动视图,但它给了我一个错误,说它只能放在一件事上.
我的活动,有一个标题textview然后是一个图像,然后是一个描述文本视图,你无法阅读整个描述,因为它很长并且低于我的屏幕边缘.如何让whoel事物可滚动?
我的xml看起来像这样:
<?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" >
<TextView
android:id="@+id/beerTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:textSize="40sp"
android:textStyle = "bold"
>
</TextView>
<ImageView android:id="@+id/image"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_margin="10dip"/>
<Button
android:id="@+id/buttonBrewery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" />
<Button
android:id="@+id/buttonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" />
<TextView
android:id="@+id/beerDEscriptionTitle"
android:textStyle = "bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:textSize="20sp"
android:text="Description"
></TextView>
<TextView
android:id="@+id/beerDescription"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:textSize="15sp"
></TextView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 用户需要在我的应用程序的注册页面中输入其权重,为此创建水平滚动视图,中心元素数据将作为用户的高度(以英寸为单位).

我尝试从Android SpinnerWheel实现Spinner Wheel Library,但它只支持int值,不支持分数.
我还尝试使用带有Center Lock库的Android HorizontalScrollView,但它不支持自动滚动.
任何人都可以建议一些示例或技巧来实现上面提到的滚动视图,中心元素值作为字段条目?
提前致谢!
我在android棒棒糖上遇到问题,当软键盘出现时,屏幕不会调整大小.
这是我所做的一项活动的明显介绍示例:
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
Run Code Online (Sandbox Code Playgroud)
是否有新的东西被添加,我们必须考虑到Android 5.0?scrollview在android <5.0上运行正常.
android android-manifest android-layout android-softkeyboard android-scrollview
主屏幕看起来像(所有这些在ConstraintLayout内):
图像描述可能太长而无法显示,为了解决这个问题,我可以把它放在ScrollView中,这样就可以了.但是,我想ScrollView整个ConstraintLayout,这不能正常工作:无法滚动,一些TextViews不会出现!
我是Android开发的新手; 帮助将不胜感激!
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/desciptionScroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.picture.nasa.nasadailyimage.NasaDailyImage"
tools:showIn="@layout/activity_nasa_daily_image">
<TextView
android:id="@+id/imageTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="@string/test_image_title"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/imageDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="@string/test_image_date"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageTitle" />
<ImageView
android:id="@+id/imageDisplay"
android:layout_width="368dp"
android:layout_height="408dp"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="3dp"
android:src="@mipmap/test_image"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageDate" />
<TextView
android:id="@+id/imageDescription"
android:layout_width="368dp"
android:layout_height="0dp"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:text="@string/test_image_description"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageDisplay" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud) 我有一个带有dinamically加载内容的scrollView.有时可能会有很多内容,所以我想在用户滚动到底部时加载更多内容.
我找到了合适的方法,发现了两个:
onScrollChanged()
Run Code Online (Sandbox Code Playgroud)
和
getScrollY()
Run Code Online (Sandbox Code Playgroud)
但我不知道如何将它用于我的目的.请给我一些建议.
我不确定什么是最好的头衔,但有了图片,我很清楚我想要什么.
我已经实现了Horizontal Scrollview,我已经定制了它,因为只显示了四个项目,如果用户想看第五个项目,那么他必须滚动它.我成功地完成了它.
但是在android 2.3.3中,当有更多项目时它会在最后显示白色视图,而在android 4.0中它没有显示.见下图:

在android 2.3中看这里,我正在显示白色视图,它清楚地告诉我,有更多按钮,但同样的结果我没有进入android 4.0或更高版本.
任何人都可以帮我如何显示它.
您可以看到我的scrollview在jellybean和kitkat中显示相同,非常棒:

但是我很震惊地看到2.2,2.3.3等较低版本中的相同内容

它似乎显示附加到屏幕上部和下部的文本的一部分.
顺便说一句,中间的线条只是带有灰色背景的文本视图.
你可以看到我的xml代码,抱歉它有点长代码
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/stars"
android:padding="5dp"
android:scrollbars="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:textColor="#fff"
android:hint="Type your Full Name here"
android:inputType="textPersonName"
android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz " >
<requestFocus />
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#330000"
android:onClick="showresult"
android:textColor="#ffffff"
android:alpha=".8"
android:text="Show My Fortune" />
<TextView
android:id="@+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:baselineAligned="false">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
<TextView
android:id="@+id/textView1"
android:layout_width="20dp"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:textSize="18sp"
/>
<TextView
android:id="@+id/textView2"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:textSize="18sp" …Run Code Online (Sandbox Code Playgroud) android textview android-layout android-2.3-gingerbread android-scrollview
我有一个问题使用ScrollView内部ConstraintLayout(constraint-layout:1.0.0-beta3)
我的ScrollView的内容没有完全显示.
这是我的布局:
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_test"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="#212121">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Constraint Layout"
android:textSize="45sp"/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/header"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="BUTTON"
android:layout_marginTop="800dp"/>
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
这是结果
正如您所看到的那样,按钮不可见,我到达了ScrollView的底部.
它似乎适用于LinearLayout,下面是布局
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_test"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#212121">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Linear Layout"
android:textSize="45sp"/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content" …Run Code Online (Sandbox Code Playgroud) android scrollview android-scrollview android-constraintlayout