- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
你好,我做了一个 ListView ,在 itemclick 上它让我进入另一个 Activity 来阅读一堆文本,但我有一个问题。如果我在 appdata.java 中添加长文本,我将无法看到所有内容,因为我无法向下滚动,基本上我想要的是创建一个 ScrollView ,以便我能够读取所有文本。
detail_activity
package com.example.test.testing.ui;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import com.example.test.testing.R;
public class DetailActivity extends AppCompatActivity {
private static final String BUNDLE_EXTRAS = "BUNDLE_EXTRAS";
private static final String EXTRA_QUOTE = "EXTRA_QUOTE";
private static final String EXTRA_ATTR = "EXTRA_ATTR";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
Bundle extras = getIntent().getBundleExtra(BUNDLE_EXTRAS);
((TextView)findViewById(R.id.lbl_quote_text)).setText(extras.getString(EXTRA_QUOTE));
((TextView)findViewById(R.id.lbl_quote_attribution)).setText(extras.getString(EXTRA_ATTR));
}
}
activity_detail.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.test.testing.ui.DetailActivity">
<TextView
android:id="@+id/lbl_quote_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium" />
<TextView
android:id="@+id/lbl_quote_attribution"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/lbl_quote_text"
android:fontFamily="sans-serif-light"
android:textStyle="italic" />
</RelativeLayout>
appdata.java
package com.example.test.testing.model;
import com.example.test.testing.R;
import java.util.ArrayList;
import java.util.List;
public class appData {
private static final String[] titles = {"Nothingness cannot be defined",
"Time is like a river made up of the events which happen, and a violent stream; " +
"for as soon as a thing has been seen, it is carried away, and another comes" +
" in its place, and this will be carried away too,",
"But when I know that the glass is already broken, every minute with it is precious.",
"For me, it is far better to grasp the Universe as it really is than to persist in" +
" delusion, however satisfying and reassuring.",
"The seeker after the truth is not one who studies the writings of the ancients and," +
" following his natural disposition, puts his trust in them, but rather the" +
" one who suspects his faith in them and questions what he gathers from them," +
" the one who submits to argument and demonstration, and not to the " +
"sayings of a human being whose nature is fraught with all kinds " +
"of imperfection and deficiency.",
"You must take personal responsibility. You cannot change the circumstances, the" +
" seasons, or the wind, but you can change yourself. That is something you" +
" have charge of."
};
private static final String[] subTitles = {"Bruce Lee",
"Marcus Aurelius",
"Meng Tzu",
"Ajahn Chah",
"Carl Sagan",
"Alhazen",
"Jim Rohn"
};
private static final int icon = R.drawable.ic_tonality_black_36dp;
public static List<ListItem> getListData() {
List<ListItem> data = new ArrayList<>();
//Repeat process 4 times, so that we have enough data to demonstrate a scrollable
//RecyclerView
for (int x = 0; x < 4; x++) {
//create ListItem with dummy data, then add them to our List
for (int i = 0; i < titles.length; i++) {
ListItem item = new ListItem();
item.setTitle(titles[i]);
item.setSubTitle(subTitles[i]);
data.add(item);
}
}
return data;
}
}
最佳答案
这可能对您有帮助:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.test.testing.ui.DetailActivity">
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/lbl_quote_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium" />
<TextView
android:id="@+id/lbl_quote_attribution"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/lbl_quote_text"
android:fontFamily="sans-serif-light"
android:textStyle="italic" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
最好在ScrollView中使用线性布局来设置正确的方向
关于java - 如何将 ScrollView 添加到我的 xml 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41833390/
我正在尝试创建一个类似于 BBC 新闻 native 应用程序的布局(使用known.js);一个垂直的ScrollView,其中有许多水平的ScrollView。我已经“工作”到了一切都渲染并且水平
我正在尝试创建一个类似于 BBC 新闻 native 应用程序的布局(使用known.js);一个垂直的ScrollView,其中有许多水平的ScrollView。我已经“工作”到了一切都渲染并且水平
我已经为以下问题寻找了很多答案,但没有找到合适的解决方案(也不是“不可能”)。我不想要双向 ScrollView! 我想要的只是拥有这样的东西: 如果我这样做(具有所需的布局属性),我会得到我的
我想使用 famo.us 标准 Scrollview但是有一个以不同速度滚动的背景图像以产生视差效果。 我想知道是否有一种方法可以连接到事件流,或者以某种方式将 Scrollviews 位置通过管道传
初始化程序中有一个带有 ScrollView(alwaysBounceVertical: false) 的属性,但我似乎找不到它了。 有谁知道如何禁用 SwiftUI ScrollView 上的垂直弹
在你说之前 “Google 说不要这样做” 请阅读我的所有问题!! 布局: ScrollView -> RelativeLayout -> ScrollView -> RelativeLayout 第
我想在 Windows 7 上创建一种体验(使用触摸),我可以在其中拥有一个只能垂直滚动的外部 ScrollViewer(它是屏幕的大小)。在那个 ScrollViewer 中,我将有几个其他的 Sc
我知道 Google 的人要求我们不要将 Scrollable View 放在另一个 Scrollable View 中,但他们是否有任何官方声明指示我们不要这样做? 最佳答案 试试这个 注意:这里
更新Xcode11 beta3后,我发现scrollview内部 View 的阴影会在边界处被切断,但在Xcode11 beta2中还可以。我只是使用底部填充来修复它,但我认为这不是一个好的解决方案。
我的 wpf 应用程序的结构如下: 我的目标是,如果 DataGrid 超过屏幕的高度来使用它自己的 Scrollviewer。目前只使用外部的 S
我在其他应用程序中使用了 ScrollView,只添加了 style={styles.container}与风格。然而,在这个应用程序中,我正在创建我的风格 alignItems:'flex-star
这是我的布局 xml。 ... 我已经尝试过此链接中的解决方案: ScrollView Inside ScrollVie
有没有办法在 nativescript 的 ScrollView 上隐藏滚动指示器?我试过 scrollBars='none' 和 css overflow='hidden' 但它不能同时工作。谢谢
所以我有一个 ScrollView ,里面有一个 TextView 。当文本的String长于屏幕宽度时,它只是在下一行中移动。我想通过在 ScrollView 中添加 HorizontalScr
我正在尝试在 android 的水平 ScrollView 中创建一个水平 ScrollView 。第一个水平 ScrollView 工作正常。当我尝试滚动时,第二个水平 ScrollView 不起作
我在同一布局中创建了两个 ScrollView。你可以说一个平行的 ScrollView 。我想手动滚动一个 ScrollView ,作为响应,另一个 ScrollView 应该以完全相同的方式滚动。
我在 android 中设计 UI,我在另一个 HorizontalScrollView 中有一个 HorizontalScrollView。但是,子 HorizontalScrollVi
我在另一个 ScrollView 中有 ScrollView 。我想滚动内部 ScrollView ,但外部 ScrollView 只滚动。如何解决这个问题? 谢谢。 最佳答案 sv01 =
我有两个 UIScrollView,如果用户在 ScrollView 中滚动,我想让另一个 ScrollView 也滚动。我已经阅读了一个解决方案,涉及将 pangesturerecognizer 从
我以编程方式创建了 UIScrollView 并向其中添加了多个 button。 它运行良好,没有任何问题。 但我需要通过复制先前 ScrollView 的内容来创建另一个 ScrollView 。
我是一名优秀的程序员,十分优秀!