• 6
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I've a splash screen like this:

but if I open my application it will show like this:

enter image description here

This is my XML layout:

<?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:background="@android:color/holo_red_light"
tools:context=".SplashScreen">

<ImageView
    android:id="@+id/splash_icon"
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_marginTop="160dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.0"
    app:srcCompat="@mipmap/ic_concas_icon" />

<TextView
    android:id="@+id/splash_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="28dp"
    android:text="GO Tools"
    android:textColor="@android:color/white"
    android:textSize="48sp"
    android:textStyle="bold"
    app:layout_constraintEnd_toEndOf="@+id/splash_icon"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="@+id/splash_icon"
    app:layout_constraintTop_toBottomOf="@+id/splash_icon" />

<ProgressBar
    android:id="@+id/splash_progress"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="136dp"
    app:layout_constraintEnd_toEndOf="@+id/splash_icon"
    app:layout_constraintHorizontal_bias="0.506"
    app:layout_constraintStart_toStartOf="@+id/splash_icon"
    app:layout_constraintTop_toBottomOf="@+id/splash_icon" />

<TextView
    android:id="@+id/splash_status"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="204dp"
    android:text="STATUS"
    android:textAlignment="center"
    android:textColor="@android:color/white"
    android:textSize="18sp"
    android:textStyle="bold"
    app:layout_constraintEnd_toEndOf="@+id/splash_icon"
    app:layout_constraintHorizontal_bias="0.508"
    app:layout_constraintStart_toStartOf="@+id/splash_icon"
    app:layout_constraintTop_toBottomOf="@+id/splash_icon" />

I need that elements are placed correctly like Android Studio preview but if I launch my application still not work. Someone know how to do that? Thank you so much!

EDIT: Image will not load but it's correctly setted.

Looks like your layout is ok but if you want your image to be a bit more to the top of the screen you need to change it, now you are telling your image to be centered to the midle of your screen so all of your other views will be placed lower than your image. A good solution would be adding guideline and constrain your image to the guideline and not the top of your screen(that way you image will be placed a bit higher and it will change your layout look)

For example:

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

    <ImageView
        android:id="@+id/splash_icon"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_marginTop="8dp"
        android:background="@color/buttonColor"
        app:layout_constraintBottom_toTopOf="@+id/guideline3"
        app:layout_constraintHorizontal_bias="0.488"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="@+id/guideline3" />

    <TextView
        android:id="@+id/splash_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="28dp"
        android:layout_marginBottom="8dp"
        android:background="@color/buttonColor"
        android:text="GO Tools"
        android:textColor="@android:color/white"
        android:textSize="48sp"
        android:textStyle="bold"
        app:layout_constraintBottom_toTopOf="@+id/splash_progress"
        app:layout_constraintEnd_toEndOf="@+id/splash_icon"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="@+id/splash_icon"
        app:layout_constraintTop_toBottomOf="@+id/splash_icon" />

    <ProgressBar
        android:id="@+id/splash_progress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="136dp"
        android:layout_marginBottom="8dp"
        android:background="@color/buttonColor"
        app:layout_constraintBottom_toTopOf="@+id/splash_status"
        app:layout_constraintEnd_toEndOf="@+id/splash_icon"
        app:layout_constraintHorizontal_bias="0.506"
        app:layout_constraintStart_toStartOf="@+id/splash_icon"
        app:layout_constraintTop_toBottomOf="@+id/splash_icon" />

    <TextView
        android:id="@+id/splash_status"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="204dp"
        android:layout_marginBottom="8dp"
        android:background="@color/buttonColor"
        android:text="STATUS"
        android:textAlignment="center"
        android:textColor="@android:color/white"
        android:textSize="18sp"
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="@+id/splash_icon"
        app:layout_constraintHorizontal_bias="0.508"
        app:layout_constraintStart_toStartOf="@+id/splash_icon"
        app:layout_constraintTop_toBottomOf="@+id/splash_icon" />

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

Edit: this may work on your phone but I just noticed that you are using a fixed size for your views - try to avoid this because different phone have different phone sizes

  • 1
Reply Report

Your layout is depending too much on the size of the screen by constraining your views to one another and relying on various margins and vertical biases to make it work in the designer. As a result, when you move to another screen size, the layout doesn't work the way you intend.

Take a look at ConstraintLayout chains for a way to group your widgets so they center across all screen sizes. I think that a CHAIN_PACKED chain is what you need.

  • 0
Reply Report