我有两个活动。第二个活动有一个textview,该视图显示xml资源中的字符串(约600个单词)。当我想以简单的意图开始第二个活动时,它会显示黑屏超过30秒。这是因为字符串很长吗?我该如何解决?
Intent intent = new Intent(Home.this, Text.class);
startActivity(intent);
第二活动:
public class Text extends AppCompatActivity {
TextView txt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_text);
txt = findViewById(R.id.textView);
Typeface font = Typeface.createFromAsset(this.getAssets(), "B Roya.ttf");
txt.setTypeface(font);
}
}
它是布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context=".Text">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_weight="20"
android:background="@drawable/janin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:layout_weight="50"
android:paddingBottom="8dp">
<com.uncopt.android.widget.text.justify.JustifiedTextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/music"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:lineSpacingExtra="5dp"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp"
android:textColor="@android:color/white"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />
</ScrollView>
</LinearLayout>
答案 0 :(得分:1)
似乎是因为使用了下面的库,我用TextView替换了它,然后解决了:
com.uncopt.android.widget.text.justify.JustifiedTextView