-1

I've search for all Internet but can't figure this out, i have my textviews on my Images, when I rotate the phone or change to other screen size, the Text won't adapt like i want (left image) i already tried app:autoSizeTextType="uniform", wrap content, match parent, but this won't do.

Image

my xml

    <TextView
                android:id="@+id/txt_chaves"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:shadowColor="#000000"
                android:shadowDx="7"
                android:shadowDy="6"
                android:shadowRadius="1.6"
                android:textSize="30sp"
                android:text="Chaves"
                android:textColor="#ffffff"
                android:textStyle="bold"
                app:layout_constraintBottom_toTopOf="@+id/gd_end_imgs1"
                app:layout_constraintEnd_toStartOf="@+id/gd_foto_esq_dir"
                app:layout_constraintStart_toStartOf="@+id/gd_foto_esq_esq"
                app:layout_constraintTop_toTopOf="@+id/gd_start_imgs1"
                app:layout_constraintVertical_bias="0.0" />

<com.google.android.material.imageview.ShapeableImageView
                android:id="@+id/img_chaves"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:adjustViewBounds="true"
                android:clickable="true"
                android:onClick="NextChaves"
                android:scaleType="fitXY"
                app:layout_constraintBottom_toTopOf="@+id/gd_end_imgs1"
                app:layout_constraintDimensionRatio="1:1"
                app:layout_constraintEnd_toStartOf="@+id/gd_foto_esq_dir"
                app:layout_constraintHorizontal_bias="1.0"
                app:layout_constraintStart_toStartOf="@+id/gd_foto_esq_esq"
                app:layout_constraintTop_toTopOf="@+id/gd_start_imgs1"
                app:layout_constraintVertical_bias="0.0"
                app:shapeAppearanceOverlay="@style/RoundImage"
                app:srcCompat="@drawable/chaves" />
Lestat2022
  • 11
  • 6
  • Take another look at autosizing TextViews [here](https://developer.android.com/guide/topics/ui/look-and-feel/autosizing-textview#setting-textview-autosize) especially the warning about `wrap_content`. I would say that you need to size the container to the size you want and let autosize do the rest. – Cheticamp Feb 16 '22 at 20:49
  • app:autoSizeMaxTextSize="35sp" app:autoSizeMinTextSize="25sp" app:autoSizeStepGranularity="1sp" app:autoSizeTextType="uniform" using this helped in pixel2, but on 8Fold-out is still tiny – Lestat2022 Feb 17 '22 at 11:31
  • And you are setting the height/width to `0dp`? What version of Android for the 8Fold-out? Post your almost working XML code. – Cheticamp Feb 17 '22 at 12:23
  • yes 0dp in both API30 – Lestat2022 Feb 17 '22 at 12:37
  • Got it. You should have posted to the question and not an answer. I would go ahead and delete the answer. I see max text size as 26sp and not 35sp as you state. – Cheticamp Feb 17 '22 at 12:47
  • that because i've change the xml to see if it works – Lestat2022 Feb 17 '22 at 14:15
  • but possible is the layouts or the guideLines , because in another activity i have almost the same image and the text is ok for me – Lestat2022 Feb 17 '22 at 14:25

2 Answers2

0

You can create a new layout for landscape mode.

you can create one by right clicking on the res directory

New -> Android resource directory

New -> Android resource directory and filling out the prompt below.

and you can take a look at this one.

  • not UI mode but yes size option, works fine if i make small, normal, large, x large images with diferentes dp – Lestat2022 Feb 21 '22 at 14:42
0
<androidx.drawerlayout.widget.DrawerLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
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:id="@+id/drawerlayout"
android:fitsSystemWindows="true"
tools:openDrawer="start"
tools:context=".MainActivity">

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:orientation="vertical"
    android:visibility="visible"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <ImageView
            android:id="@+id/iv_background"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:adjustViewBounds="true"
            android:alpha="0.7"
            android:backgroundTint="#80FFFFFF"
            android:backgroundTintMode="src_over"
            android:contentDescription="TODO"
            android:scaleType="fitXY"
            android:src="@drawable/slideshow"
            app:layout_constraintBottom_toTopOf="@+id/gd_imagemP_baixo"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@+id/gd_imagemP_cima"
            app:layout_constraintVertical_bias="1.0"
            tools:ignore="ImageContrastCheck" />

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

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

        <androidx.constraintlayout.widget.Guideline
            android:id="@+id/gd_foto_esq_esq"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.15" />

        <androidx.constraintlayout.widget.Guideline
            android:id="@+id/gd_foto_esq_dir"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.45" />

        <androidx.constraintlayout.widget.Guideline
            android:id="@+id/gd_foto_dir_esq"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.55" />

        <androidx.constraintlayout.widget.Guideline
            android:id="@+id/gd_foto_dir_dir"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.85" />

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

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

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

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

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

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

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

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

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

        <androidx.constraintlayout.widget.Guideline
            android:id="@+id/gd_end_2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintGuide_percent="1.0" />
        <androidx.constraintlayout.widget.Guideline
            android:id="@+id/gd_texto_cima"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintGuide_percent="0.35" />
        <androidx.constraintlayout.widget.Guideline
            android:id="@+id/gd_texto_baixo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintGuide_percent="0.35" />

        <HorizontalScrollView
            android:id="@+id/horizontalScrollView"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:background="#CDECFC"
            android:fillViewport="true"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintVertical_bias="0.0"
            tools:ignore="MissingConstraints">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                tools:openDrawer="start"
                android:orientation="horizontal">
                <!--Menu layouts-->

                <androidx.appcompat.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:background="#CDECFC"
                    android:layout_gravity="start"
                    android:fitsSystemWindows="true"
                    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintHorizontal_bias="1.0"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:layout_constraintVertical_bias="0.0"
                    />

            </androidx.constraintlayout.widget.ConstraintLayout>
        </HorizontalScrollView>
        <!--Fim do Horizontal view-->
        <androidx.constraintlayout.widget.Guideline
            android:id="@+id/guideline2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.35" />

        <androidx.constraintlayout.widget.Guideline
            android:id="@+id/guideline3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.65" />

        <com.google.android.material.imageview.ShapeableImageView
            android:id="@+id/img_chaves"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:adjustViewBounds="true"
            android:scaleType="fitXY"
            android:clickable="true"
            android:onClick="NextChaves"
            app:layout_constraintBottom_toTopOf="@+id/gd_end_imgs1"
            app:layout_constraintDimensionRatio="1:1"
            app:layout_constraintEnd_toStartOf="@+id/gd_foto_esq_dir"
            app:layout_constraintStart_toStartOf="@+id/gd_foto_esq_esq"
            app:layout_constraintTop_toTopOf="@+id/gd_start_imgs1"
            app:shapeAppearanceOverlay="@style/RoundImage"
            app:srcCompat="@drawable/chaves" />

        <TextView
            android:id="@+id/txt_chaves"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:gravity="center_horizontal"
            android:shadowColor="#000000"
            android:shadowDx="7"
            android:shadowDy="6"
            android:shadowRadius="1.6"
            android:text="Chaves"
            android:textColor="#ffffff"
            android:textStyle="bold"
            app:autoSizeMaxTextSize="26sp"
            app:autoSizeMinTextSize="25sp"
            app:autoSizeStepGranularity="1sp"
            app:autoSizeTextType="uniform"
            app:layout_constraintBottom_toTopOf="@+id/gd_end_imgs1"
            app:layout_constraintDimensionRatio="1:1"
            app:layout_constraintEnd_toStartOf="@+id/gd_foto_esq_dir"
            app:layout_constraintStart_toStartOf="@+id/gd_foto_esq_esq"
            app:layout_constraintTop_toTopOf="@+id/gd_start_imgs1"
            app:layout_constraintVertical_bias="0.0" />

the rest of code is more images and textview and a navigationview for one menu

Lestat2022
  • 11
  • 6
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 17 '22 at 13:18