user1712775
user1712775

Reputation:

Android's black screen reason

I have two activities. The second activity has a textview that shows a string(about 600 words) from xml resources. When I want to start the second activity with a simple intent it shows the black screen for more than 30 seconds. Is this because of a long string? How i can solve this?

Intent intent = new Intent(Home.this, Text.class);
startActivity(intent);

Second avtivity:

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);
    }
}

and it's a layout:

  <?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>

Upvotes: 0

Views: 91

Answers (1)

user1712775
user1712775

Reputation:

Seems it was because of using below library and i replaced it with TextView then it solved:

com.uncopt.android.widget.text.justify.JustifiedTextView

Upvotes: 1

Related Questions