Absolute focus on android

1

I have problems when it comes to centering 2 elements in my android interface, the first one is an imageview, try to change the size of the image thinking it was because of its size but nothing happens, it looks like this:



When what I'm looking for is something like this:



My code is this:

<android.support.design.widget.CoordinatorLayout
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/colorPrimary"
>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="1">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.6"
        >

        <ImageView
            android:id="@+id/logo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:background="@drawable/logo"
            />

    </RelativeLayout>

As you can see use the property:

android:layout_centerInParent="true"

In the imageview but it does not adjust the size.

The same goes for the textview Do not have an account? my code is:

<ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.4"
        android:fillViewport="true"
        >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:padding="@dimen/padding_horizontal_login"
            >

            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/EditTextWhite"
                >

                <android.support.design.widget.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/username"
                    android:hint="@string/hint_username"
                    />
            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/EditTextWhite">

                <android.support.design.widget.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/password"
                    android:hint="@string/hint_password"
                    android:inputType="textPassword"
                    />
            </android.support.design.widget.TextInputLayout>

            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/login"
                android:text="@string/btn_login"
                android:background="@color/colorPrimaryDark"
                android:theme="@style/RaisedButtonDark"
                />

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center"
                >
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/dontHaveAccount"
                    android:text="@string/dont_have_account"
                    android:textColor="@color/colorTextIcons"
                    android:textStyle="bold"
                    android:textSize="@dimen/textsize_donthaveaccount"
                    />
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:id="@+id/createHere"
                    android:text="@string/create_here"
                    android:textColor="@color/colorTextIcons"
                    android:textStyle="bold"
                    android:textSize="@dimen/textsize_donthaveaccount"
                    android:layout_toRightOf="@id/dontHaveAccount"
                    />
            </RelativeLayout>
        </LinearLayout>

    </ScrollView>

As you can see in the RelativeLayout use:

android:gravity="center

But I do not center the content either.

    
asked by DVertel 13.10.2017 в 21:30
source

1 answer

0

In this case you are using a CoordinatorLayout , if you want to center your elements , you have the advantage of doing it through the design view, select your element and when viewing the circles, drag them to the 4 ends, with this when you run your application the elemp

    
answered by 13.10.2017 в 22:10