Criei um Custom Listview com alguns itens mas como podem ver na imagem abaixo fica um "espaço vazio" na tela.
Gostaria de saber como faço para que os itens ocupem todo o espaço restante na tela.
Código do Menu.java:
public class Menu extends Activity{
private List<MenuItensAndIcons> menuitens = new ArrayList<MenuItensAndIcons>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menulistview);
CriandoItensMenu();
CriandoListView();
final UsuarioLogado usuariologado = (UsuarioLogado) getApplicationContext();
getActionBar().setTitle(usuariologado.getUsuariologado());
getActionBar().setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
}
private void CriandoItensMenu() {
menuitens.add(new MenuItensAndIcons("Cadastrar", R.drawable.add));
menuitens.add(new MenuItensAndIcons("Meus Cadastros", R.drawable.consulta));
menuitens.add(new MenuItensAndIcons("Perfil", R.drawable.neutro));
menuitens.add(new MenuItensAndIcons("Mapa", R.drawable.mapa));
menuitens.add(new MenuItensAndIcons("Consulta Avançada", R.drawable.consulta));
}
private void CriandoListView() {
ArrayAdapter<MenuItensAndIcons> arrayadapter = new MyListAdapter();
ListView listamenu = (ListView)findViewById(R.id.menulist);
listamenu.setAdapter(arrayadapter);
}
private class MyListAdapter extends ArrayAdapter<MenuItensAndIcons>{
public MyListAdapter(){
super(Menu.this, R.layout.item_view, menuitens);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View itemview = convertView;
if(itemview == null){
itemview = getLayoutInflater().inflate(R.layout.item_view, parent, false);
}
//achar o item especifico
MenuItensAndIcons itematual = menuitens.get(position);
//preenche os dados do listview
ImageView imageview = (ImageView)itemview.findViewById(R.id.ItemIcon);
imageview.setImageResource(itematual.getIconeMenu());
TextView Textitem = (TextView)itemview.findViewById(R.id.item_TextItem);
Textitem.setText(""+itematual.getNomeMenu());
return itemview;
}
}
Código do menulistview.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/menulist"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</LinearLayout>
Código do item_view.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/ItemIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/add" />
<TextView
android:id="@+id/item_TextItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/ItemIcon"
android:layout_marginBottom="16dp"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/ItemIcon"
android:text="Text Aqui"
android:textColor="@android:color/white" />
</RelativeLayout>