1
I used Gravity.CENTER
, what centered the text in Edittext and not Edittext in Activity.
package com.example.wbsoftware.testetcc;
import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
public class Main2Activity extends AppCompatActivity {
private LinearLayout layout;
private EditText[] vetorEdits;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
layout = (LinearLayout) findViewById(R.id.layout);
int count = getIntent().getIntExtra("qtd", 0);
vetorEdits = new EditText[count];
for(int i=0; i<count; i++){
vetorEdits[i] = new EditText(Main2Activity.this);
vetorEdits[i].setHint("Periodo " + (i+1));
vetorEdits[i].setHintTextColor(Color.WHITE);
vetorEdits[i].setGravity(Gravity.CENTER);
vetorEdits[i].setTextColor(Color.WHITE);
layout.addView(vetorEdits[i], new ViewGroup.LayoutParams(300,150));
}
}
}
Thanks, I got!
– Wesley
@Hacker If the response of the regmoraes solved your problem, mark his answer as correct.
– Túlio Calazans