layout problems in Android Studio

Asked

Viewed 382 times

3

I’m having a little problem with my layout looks like this in Android Studio and how it looks on Avd:

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

xml code:

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="@string/Linha1"
    android:id="@+id/textView"
    android:layout_alignParentLeft="true"
    android:layout_marginLeft="0dp"
    android:layout_alignParentTop="true"
    android:layout_marginTop="20dp" />

<EditText
    android:layout_width="46dp"
    android:layout_height="wrap_content"
    android:inputType="number|numberSigned|numberDecimal"
    android:ems="10"
    android:id="@+id/A1"
    android:layout_alignBaseline="@+id/textView"
    android:layout_alignBottom="@+id/textView"
    android:layout_toRightOf="@+id/textView"
    android:layout_toEndOf="@+id/textView" />

<EditText
    android:layout_width="46dp"
    android:layout_height="wrap_content"
    android:inputType="number|numberSigned|numberDecimal"
    android:ems="10"
    android:id="@+id/B1"
    android:layout_above="@+id/textView2"
    android:layout_toRightOf="@+id/textView4"
    android:layout_toEndOf="@+id/textView4" />

<EditText
    android:layout_width="46dp"
    android:layout_height="wrap_content"
    android:inputType="number|numberSigned|numberDecimal"
    android:ems="10"
    android:id="@+id/C1"
    android:layout_above="@+id/textView2"
    android:layout_toRightOf="@+id/textView7"
    android:layout_toEndOf="@+id/textView7" />

<EditText
    android:layout_width="46dp"
    android:layout_height="wrap_content"
    android:inputType="number|numberSigned|numberDecimal"
    android:ems="10"
    android:id="@+id/K1"
    android:accessibilityLiveRegion="polite"
    android:layout_above="@+id/textView2"
    android:layout_toRightOf="@+id/textView10"
    android:layout_toEndOf="@+id/textView10" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="@string/Linha2"
    android:id="@+id/textView2"
    android:layout_marginTop="41dp"
    android:layout_below="@+id/A1"
    android:layout_toLeftOf="@+id/A1"
    android:layout_toStartOf="@+id/A1" />

<EditText
    android:layout_width="46dp"
    android:layout_height="wrap_content"
    android:inputType="number|numberSigned|numberDecimal"
    android:ems="10"
    android:id="@+id/A2"
    android:layout_alignBaseline="@+id/textView2"
    android:layout_alignBottom="@+id/textView2"
    android:layout_toRightOf="@+id/textView2"
    android:layout_toEndOf="@+id/textView2" />

<EditText
    android:layout_width="46dp"
    android:layout_height="wrap_content"
    android:inputType="number|numberSigned|numberDecimal"
    android:ems="10"
    android:id="@+id/B2"
    android:accessibilityLiveRegion="polite"
    android:layout_alignTop="@+id/A2"
    android:layout_toRightOf="@+id/textView5"
    android:layout_toEndOf="@+id/textView5" />

<EditText
    android:layout_width="46dp"
    android:layout_height="wrap_content"
    android:inputType="number|numberSigned|numberDecimal"
    android:ems="10"
    android:id="@+id/C2"
    android:layout_above="@+id/textView3"
    android:layout_toRightOf="@+id/textView8"
    android:layout_toEndOf="@+id/textView8" />

<EditText
    android:layout_width="46dp"
    android:layout_height="wrap_content"
    android:inputType="number|numberSigned|numberDecimal"
    android:ems="10"
    android:id="@+id/K2"
    android:layout_alignTop="@+id/A2"
    android:layout_alignLeft="@+id/K1"
    android:layout_alignStart="@+id/K1" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="@string/Linha3"
    android:id="@+id/textView3"
    android:layout_marginTop="37dp"
    android:layout_below="@+id/A2"
    android:layout_toLeftOf="@+id/A1"
    android:layout_toStartOf="@+id/A1" />

<EditText
    android:layout_width="46dp"
    android:layout_height="wrap_content"
    android:inputType="number|numberSigned|numberDecimal"
    android:ems="10"
    android:id="@+id/A3"
    android:layout_alignBaseline="@+id/textView3"
    android:layout_alignBottom="@+id/textView3"
    android:layout_toRightOf="@+id/textView3"
    android:layout_toEndOf="@+id/textView3" />

<EditText
    android:layout_width="46dp"
    android:layout_height="wrap_content"
    android:inputType="number|numberSigned|numberDecimal"
    android:ems="10"
    android:id="@+id/B3"
    android:layout_alignTop="@+id/A3"
    android:layout_alignLeft="@+id/B2"
    android:layout_alignStart="@+id/B2" />

<EditText
    android:layout_width="46dp"
    android:layout_height="wrap_content"
    android:inputType="number|numberSigned|numberDecimal"
    android:ems="10"
    android:id="@+id/C3"
    android:layout_alignTop="@+id/B3"
    android:layout_toRightOf="@+id/textView9"
    android:layout_toEndOf="@+id/textView9" />

<EditText
    android:layout_width="46dp"
    android:layout_height="wrap_content"
    android:inputType="number|numberSigned|numberDecimal"
    android:ems="10"
    android:id="@+id/K3"
    android:layout_alignBottom="@+id/C3"
    android:layout_alignLeft="@+id/K2"
    android:layout_alignStart="@+id/K2" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Calcular"
    android:id="@+id/button"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:singleLine="false"
    android:textColor="#54b2c7" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Limpar"
    android:id="@+id/Limpar"
    android:layout_below="@+id/button"
    android:layout_centerHorizontal="true"
    android:onClick="LimparCampos" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="@string/x1"
    android:id="@+id/textView4"
    android:layout_alignTop="@+id/textView"
    android:layout_toRightOf="@+id/A1"
    android:layout_toEndOf="@+id/A1" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="@string/x2"
    android:id="@+id/textView5"
    android:layout_alignTop="@+id/textView2"
    android:layout_toRightOf="@+id/A2"
    android:layout_toEndOf="@+id/A2" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="@string/x3"
    android:id="@+id/textView6"
    android:layout_alignTop="@+id/textView3"
    android:layout_toRightOf="@+id/A3"
    android:layout_toEndOf="@+id/A3" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="@string/y1"
    android:id="@+id/textView7"
    android:layout_alignTop="@+id/textView4"
    android:layout_toRightOf="@+id/B1"
    android:layout_toEndOf="@+id/B1" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="@string/y2"
    android:id="@+id/textView8"
    android:layout_alignTop="@+id/textView5"
    android:layout_toRightOf="@+id/B2"
    android:layout_toEndOf="@+id/B2" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="@string/y3"
    android:id="@+id/textView9"
    android:layout_alignTop="@+id/textView6"
    android:layout_toRightOf="@+id/B3"
    android:layout_toEndOf="@+id/B3" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="@string/z1"
    android:id="@+id/textView10"
    android:layout_alignBottom="@+id/textView7"
    android:layout_toRightOf="@+id/C1"
    android:layout_toEndOf="@+id/C1" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="@string/z2"
    android:id="@+id/textView11"
    android:layout_alignTop="@+id/textView8"
    android:layout_toLeftOf="@+id/K2"
    android:layout_toStartOf="@+id/K2" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="@string/z3"
    android:id="@+id/textView12"
    android:layout_alignTop="@+id/textView9"
    android:layout_toRightOf="@+id/C3"
    android:layout_toEndOf="@+id/C3" />

I would also like to know how and what I do for when I click enter it go to the editText from the side and not to the one that’s down and when he gets to the last he goes back to the first from below.

  • The design shown in Android Studio is just a reference of how it will look. You have to pay attention to XML and its settings.

2 answers

3


Try adding nextFocusDown to each Edittext

android:nextFocusDown="@+id/.."

For example

<EditText
    android:layout_width="46dp"
    android:layout_height="wrap_content"
    android:inputType="number|numberSigned|numberDecimal"
    android:ems="10"
    android:id="@+id/A1"
    android:nextFocusDown="@+id/B1"
    android:layout_alignBaseline="@+id/textView"
    android:layout_alignBottom="@+id/textView"
    android:layout_toRightOf="@+id/textView"
    android:layout_toEndOf="@+id/textView" />

<EditText
    android:layout_width="46dp"
    android:layout_height="wrap_content"
    android:inputType="number|numberSigned|numberDecimal"
    android:ems="10"
    android:id="@+id/B1"
    android:layout_above="@+id/textView2"
    android:layout_toRightOf="@+id/textView4"
    android:layout_toEndOf="@+id/textView4" />

That way when you click Edittext A1 Enter, Edittext B1 wins Focus. I hope I helped.

1

In the xml inside the Activity tag set your screenOrientation to Portrait, example:

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".activity.HomeActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar"
        **android:screenOrientation="portrait"**
        >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.