Hi All,
I am attempting to get a display layout like this: a thin header row
at the top, thick body row underneath it within a scroll bar, and a
thin footer row at the bottom. The footer row contains images and
should not be "compressed" vertically.
When scrolling the body, header and footer displays remain in place.
I some code but it's not working properly: when the body with the
ScrollView is added to the main LinearLayout object, the footer row
does not display anymore. If I take out the body section, the footer
row appears again. Why does this happen?
Thanks in advance!
My Activity: (ignore background colors, used for debugging; also,
there may seem to be extraneous layout objects used, but in my real
project, I need them for more complicated displays)
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout mainLayout = new LinearLayout(this);
mainLayout.setOrientation(LinearLayout.VERTICAL);
mainLayout.setBackgroundColor(Color.YELLOW);
//
// HEADER
//
TextView tv = new TextView(this);
tv.setText("HEADER");
tv.setBackgroundColor(Color.BLUE);
tv.setGravity(Gravity.CENTER);
mainLayout.addView(tv, new
ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
final Activity thisAct = this;
//
// BODY
//
LinearLayout bodyLayout = new LinearLayout(this);
bodyLayout.setBackgroundColor(Color.RED);
TextView myText = new TextView(this);
myText.setText(getString() + getString());
ScrollView scrollView = new ScrollView(this);
scrollView.addView(myText);
scrollView.setScrollContainer(true);
bodyLayout.addView(scrollView);
bodyLayout.setScrollContainer(true);
mainLayout.addView(bodyLayout);
//
// FOOTER
//
LinearLayout footerLayout = new LinearLayout(this);
footerLayout.setGravity(Gravity.BOTTOM);
TextView tv2 = new TextView(this);
tv2.setText("FOOTER");
tv2.setBackgroundColor(Color.GRAY);
tv2.setGravity(Gravity.BOTTOM | Gravity.CENTER);
mainLayout.addView(tv2, new
ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT) );
setContentView(mainLayout);
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en