gpt4 book ai didi

android - 滚动和缩放Textview之间的冲突

转载 作者:行者123 更新时间:2023-11-29 14:12:25 25 4
gpt4 key购买 nike

我在使用 Textview 时遇到了一些问题。我已经为我的应用程序编写了这段代码。如果需要,我希望能够捏一下来缩放和滚动 Textview。我编写了用于缩放的代码并且它可以正常工作但是如果我插入用于 TextView 滚动的代码它不起作用,但是滚动可以正常工作。如果我删除滚动代码,我可以捏合缩放,但如果文本对于页面来说太长,我就无法滚动它。我的代码有什么问题?

布局代码:

<TextView
android:id="@+id/tv_testo_canzone"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="40dp"
android:layout_marginTop="90dp"
android:scrollbars="vertical"
android:text="TextView"
android:textAlignment="center"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

主要代码:

tv_testo_canzone = (TextView) findViewById(R.id.tv_testo_canzone);
tv_titolo = (TextView) findViewById(R.id.tv_titolo_canz);
tv_artista = (TextView) findViewById(R.id.tv_artista_canz);

tv_testo_canzone.setMovementMethod(new ScrollingMovementMethod());
linearLayout1 = (RelativeLayout) findViewById(R.id.layout_canzone);

try {
reader = new BufferedReader(
new InputStreamReader(getAssets().open(nomeTxt)));

// do reading, usually loop until end of file reading
String mLine;
while ((mLine = reader.readLine()) != null) {
text.append(mLine);
text.append('\n');
}
} catch (IOException e) {
Toast.makeText(getApplicationContext(),"Error reading file!",Toast.LENGTH_LONG).show();
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
//log the exception
}
}

tv_testo_canzone.setText((CharSequence) text);

}

最佳答案

代码没有任何问题,当您使用 ScrollView 时认为它的所有 subview 都没有收到手势,因为它们都由父 ScrollView 处理

关于android - 滚动和缩放Textview之间的冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51315091/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com