Home > OS >  How to adjust Text Views in different Screens (Android Studio)
How to adjust Text Views in different Screens (Android Studio)

Time:02-18

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.

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

and you can take a look at this one.

CodePudding user response:

<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

  • Related