Android Studio new project, Vista not complete

2

Create a project of 0 and when making the first view I get a space like a header that does not let me occupy my layout any idea that it is

this is my manifest

<?xml version="1.0" encoding="utf-8"?>

                        

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">


    <activity android:name=".DeviceAssociation"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>

this is my view

<?xml version="1.0" encoding="utf-8"?>

android:id="@+id/ScrollView01"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="130dp"
        >

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:background="@mipmap/mm_logo" />
    </RelativeLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingLeft="35dp"
        android:paddingRight="35dp"
        android:paddingTop="25dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/welcome"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="@string/activity_login_welcome_t1"
                android:textAlignment="center"
                android:textColor="@color/colorPrimaryDark"
                android:textSize="15sp"
                android:textStyle="bold" />

        </RelativeLayout>



        <GridLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="40dp"
            android:background="@drawable/round_border"
            android:orientation="vertical"
            android:focusable="true" android:focusableInTouchMode="true">

            <EditText
                android:id="@+id/cellphoneText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/Cellphone"
                android:inputType="text"
                android:maxLength="30"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
               />
            <EditText
                android:id="@+id/passwordText"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:hint="@string/activation_password"
                android:inputType="textPassword"
                android:maxLength="15"
                android:text=""
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                />
        </GridLayout>



        <Button
            android:id="@+id/buttonEnter"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/round_border"
            android:onClick="goToStepHome"
            android:text="@string/activity_login_loginButton"
            android:layout_marginTop="15dp"
            />


        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="15dp">



            <TextView
                android:id="@+id/TextoMuestra"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:text="@string/activity_login_register_t1"
                android:textSize="15dp"

                android:textStyle="bold" />

            <TextView
                android:layout_width="wrap_content"
                android:id="@+id/TextoMuestraa"
                android:layout_height="wrap_content"
                android:clickable="true"
                android:gravity="end"
                android:layout_centerHorizontal="true"
                android:layout_below="@+id/TextoMuestra"
                android:onClick="goToRegistration"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:text="@string/activity_login_register_t2"
                android:textColor="@color/colorPrimaryDark"
                android:textSize="17dp"
                android:textStyle="bold" />

        </RelativeLayout>
    </LinearLayout>
</LinearLayout>

Activity Code

  package banred.twoinnovateit.com.bimo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.TextView;


/*
*Create by: Bruno Sosa
*Date: 17-10-2017
*Description: Actividad para la verificacion del enrolamiento del numero del dispositivo con la cuenta
*/

public class DeviceAssociationConfirmation extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_device_association_confirmation);
        showToolbar(getResources().getString(R.string.TitleDeviceAssociation),
                getResources().getString(R.string.SubTitleDeviceAssociation), R.drawable.mm_cash_out_400, false);
    }
     /*
    *Description: Metodo para mostrar datos en el toolbar
    */

    public void showToolbar(String tittle, String subTittle, int image, boolean upButton) {
        Toolbar toolbar = (Toolbar) findViewById(R.id.actionbar_toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setTitle(tittle);
        getSupportActionBar().setDisplayHomeAsUpEnabled(upButton);
        TextView title = (TextView) findViewById(R.id.title);
        TextView subTitle = (TextView) findViewById(R.id.subTitle);
        title.setText(tittle);
        subTitle.setText(subTittle);

    }


}
    
asked by Bruno Sosa Fast Tag 17.10.2017 в 21:05
source

1 answer

1

With respect to space, it is actually the height defined in this layout:

   <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="130dp"
        >

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:background="@mipmap/mm_logo" />
    </RelativeLayout>

In this case you can change your property to android:layout_height="wrap_content" :

  <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >

or just do not use it and just define your ImageView .

Regarding the error:

  

java.lang.IllegalStateException: This Activity has already an action   bar supplied by the window decor. Do not request   Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in   your theme to use a Toolbar instead.

the theme defined for your Activity in styles.xml must have these 2 properties that indicate not showing a ActionBar since it is not necessary because you are adding a Toolbar :

   ...
    ...
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>
    
answered by 17.10.2017 / 22:00
source