How to put the default styles of android ex .. edittext spinner etc

2

I'm in need of some help. My android app is in trouble, all the elements I add it plays on the screen in a different way.

Ex: when I add an EditText it does not stick to the border only shows the same when it gains focus and so to the others

Can you solve this if there is no way I can redo it? Follow the image below with the real problem.

followcodes

activity_finance_alterar.xml

<Spinnerandroid:layout_width="350dp"
    android:layout_height="wrap_content"
    android:id="@+id/SPAtlerarResultado"
    android:textColor="@color/font"
    android:layout_below="@+id/tvAlterarConsultor"
    android:layout_alignLeft="@+id/tvAlterarConsultor"
    android:layout_alignStart="@+id/tvAlterarConsultor"
    android:layout_marginTop="26dp"
    android:drawableRight="@drawable/spinner_triangulo"
    android:prompt="@string/textospiner"
    android:drawSelectorOnTop="true"
    />

financial_alterar_spinner.xml

<TextView
    android:layout_width="wrap_content"

    android:text="Resultado"
    android:textColor="@color/font"
    android:id="@+id/tvAlterarResultado"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_height="48dp"
    android:gravity="center_vertical|start"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:textSize="18dp"

   />

.class

Spinner sp = (Spinner) findViewById(R.id.SPAtlerarResultado);
sp.setPrompt("Selecione um resultado");

sp.setAdapter(new FinanceiroResultadoAdapter(FinanceiroAlterar.this, resultados));

My adapter is like this.

public View getView(int position, View convertView, ViewGroup parent) {

    FinanceiroResultado resultado = lista.get(position);
    View layout;

    if(convertView == null){
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        layout = inflater.inflate(R.layout.financeiro_alterar_spinner, null);
    }
    else{
        layout = convertView;
    }
    TextView nome = (TextView) layout.findViewById(R.id.tvAlterarResultado);
    nome.setText(resultado.getDs_resultadofinanceiro());


    return layout;
}
    
asked by anonymous 21.07.2015 / 21:49

1 answer

1

If this image you posted is related to your project, possibly it should be overlapping your layout, you could create a file to define the shape you want, for example:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >

<!-- background do seu shape -->

<solid android:color="#00000000" >
</solid>
 <!-- cor da borda e tamanho -->
<stroke
    android:width="1dp"
    android:color="#ffffff" >
</stroke>

<!-- aqui voce adiciona o padding desejado -->
<padding
    android:bottom="4dp"
    android:left="4dp"
    android:right="4dp"
    android:top="4dp" >
</padding>

<!-- Radius -->
<corners android:radius="5dp" >
</corners>

When you assign the layout to the editText it would look something like:

<RelativeLayout
        <!-- demais configs. omitidas -->
        android:background="@layout/shapelogin" >


 <EditText
          android:id="@+id/txtUsuario"

  </EditText>
    </RelativeLayout>

Note: The shape of the layout changes according to the theme you use, so the version 2.3 spinner is not the same as version 4.4 or 5.0. One way around this is to create a style.xml and customize it to the best of your layout.

For your spinner you can set this at the time of setting the adapter something like:

adapterConexoesListView = new AdapterConexoesListView(this, android.R.layout.simple_spinner_dropdown_item, listaConexao)

EDIT: In the builder of your adapter pass the new example parameter:

public AdapterConexoesListView(ConexaoSettingsSpinnerActivity context, int simpleSpinnerItem, List<Conexao> listaConexao)

Where simple_spinner_dropdown_item will be displayed as follows:

Oryoucanusesimple_spinner_item

However you can customize letters, font size by defining your spinner layout.

    
22.07.2015 / 17:02