Android Studio - Alert Box - большой - PullRequest
       27

Android Studio - Alert Box - большой

0 голосов
/ 02 февраля 2020

Здравствуйте, я новичок в Androidstudio

Я пытался исправить Alertbox около 2 часов, но я не понимаю, что с ним не так.

Вот изображение Alertbox

Picture of the not properly Working Alertbox Alertbox должен заканчиваться после слова "WEITER" (Да, я говорю по-немецки.) Я надеюсь, мы сможем выяснить, в чем проблема. Внизу есть вся соответствующая информация.

Вот код XML, используемый для Alertbox:

    <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:id="@+id/textView_helpText"
        android:layout_width="411dp"
        android:layout_height="113dp"
        android:elegantTextHeight="true"
        android:fontFamily="casual"
        android:gravity="center"
        android:includeFontPadding="true"
        android:padding="2dp"
        android:text="Hallo"
        app:autoSizeTextType="uniform"
        app:layout_constraintBottom_toTopOf="@+id/button_helpNext"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/view3" />

    <Button
        android:id="@+id/button_helpNext"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="@drawable/fragment_active_button"
        android:text="Weiter"
        app:layout_constraintBottom_toTopOf="@+id/guideline71"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/guideline75" />

    <View
        android:id="@+id/view3"
        android:layout_width="411dp"
        android:layout_height="55dp"
        android:background="@color/fragmentButtonColor"
        app:layout_constraintBottom_toTopOf="@+id/guideline70"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/guideline70"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="00.075" />

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/guideline71"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.28" />

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/guideline75"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.23" />


</androidx.constraintlayout.widget.ConstraintLayout>

Последний, но не наименее setOnClickListener для запуска Aleartbox

final Кнопка helpButton = findViewById (R.id.button_help) ;; helpButton.setOnClickListener (новый View.OnClickListener () {

    @Override
    public void onClick(View v) {

        AlertDialog.Builder helpDialog = new AlertDialog.Builder(SecondActivity.this);
        View helpView = getLayoutInflater().inflate(R.layout.dialog_help,null);


        Resources res = getResources();
        String[] helpText = res.getStringArray(R.array.planets_array);

        final ArrayList<String> list= new ArrayList<>();

        for(String s :helpText){
            list.add(s);
        }

        final TextView helpTextView = helpView.findViewById(R.id.textView_helpText);
        helpTextView.setText(list.get(0));

        Button helpNext = helpView.findViewById(R.id.button_helpNext);


        helpNext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(list.size()>1) {
                    list.remove(0);
                    helpTextView.setText(list.get(0));
                }else{
                   finish();
                    setContentView(R.layout.activity_settings);
                }
            }
        });



        helpDialog.setView(helpView);
        AlertDialog help = helpDialog.create();
        help.show();

    }
});

1 Ответ

1 голос
/ 03 февраля 2020

Возможно, проблема в

    android:layout_height="match_parent"

Попробуйте изменить его на android:layout_height="wrap_content"

...