Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Layout with ListView and Buttons
    text
    copied!<p>Alright, this specific layout is just annoying me. And can't seem to find a way to have a listView, with a row of buttons at the bottom so that the listview doesn't extend over top of the buttons, and so the buttons are always snapped to the bottom of the screen. Here's what I want:</p> <p><em>removed dead ImageShack link</em></p> <p>It seems like it should be so easy, but everything I've tried has failed. Any help?</p> <p>Here's my current code:</p> <pre><code> RelativeLayout container = new RelativeLayout(this); container.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); //** Add LinearLayout with button(s) LinearLayout buttons = new LinearLayout(this); RelativeLayout.LayoutParams bottomNavParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); bottomNavParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); bottomNavParams.addRule(RelativeLayout.CENTER_HORIZONTAL); buttons.setLayoutParams(bottomNavParams); ImageButton newLayer = new ImageButton(this); newLayer.setImageResource(R.drawable.newlayer); newLayer.setLayoutParams(new LinearLayout.LayoutParams(45, LayoutParams.FILL_PARENT)); buttons.addView(newLayer); container.addView(buttons); //** Add ListView layerview = new ListView(this); RelativeLayout.LayoutParams listParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); listParams.addRule(RelativeLayout.ABOVE, buttons.getId()); layerview.setLayoutParams(listParams); container.addView(layerview); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload