3

Estou com um pequeno problema com meu layout olha como esta no Android Studio e como fica na avd:

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

código XMl:

<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" />

Gostaria da saber também como e que eu faço para quando eu clicar em enter ele ir para a editText do lado e não para a que ta em baixo e quando ele chegar na última ele volte para a primeira de baixo.

1
  • O design mostrado no Android Studio é só uma referência de como vai ficar. Tens de ter em atenção o XML e as sua definições.
    – Jorge B.
    Commented 1/12/2015 às 13:56

2 Respostas 2

3

Tente adicionar nextFocusDown em cada EditText

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

Por exemplo

<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" />

Dessa forma quando clicar em Enter do EditText A1, o EditText B1 ganha o focus. Espero ter ajudado.

1

No xml dentro da tag dessa activity set sua screenOrientation para portrait, exemplo:

<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>

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .