Return to Snippet

Revision: 56255
at March 18, 2012 00:49 by BenClayton


Initial Code
TextView tv = new TextView(this);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
tv.setLayoutParams( layoutParams );
tv.setText(getString(R.string.loading));
tv.setGravity(Gravity.CENTER_HORIZONTAL);
layout.addView(tv);

Initial URL


Initial Description
This example adds a horizontally-centered TextView to the bottom of the RelativeLayout called 'layout'.

Initial Title
Dynamically add widget / TextView to a RelativeLayout in code

Initial Tags
android

Initial Language
Java