How to add a view programmatically to RelativeLayout?

Heres an example to get you started, fill in the rest as applicable: TextView tv = new TextView(mContext); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.leftMargin = 107 … mRelativeLayout.addView(tv, params); The docs for RelativeLayout.LayoutParams and the constructors are here

How do I programmatically remove an existing rule that was defined in XML?

You can’t remove a rule because all rules are always stored in a fixed-size java array. But you can set a rule to 0. For example layoutParams.addRule(RelativeLayout.RIGHT_OF, 0); layoutParams.addRule(RelativeLayout.BELOW, R.id.new_ref_LinearLayout); EDIT (thanks to Roger Rapid): As of API level 17, the class RelativeLayout.LayoutParams has the following method: public void removeRule(int verb) So you can remove … Read more

LinearLayout vs RelativeLayout [closed]

Read this article: The Android UI toolkit offers several layout managers that are rather easy to use and, most of the time, you only need the basic features of these layout managers to implement a user interface. Sticking to the basic features is unfortunately not the most efficient way to create user interfaces. A common … Read more

How to create a RelativeLayout programmatically with two buttons one on top of the other?

I have written a quick example to demonstrate how to create a layout programmatically. public class CodeLayout extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Creating a new RelativeLayout RelativeLayout relativeLayout = new RelativeLayout(this); // Defining the RelativeLayout layout parameters. // In this case I want to fill its parent RelativeLayout.LayoutParams rlp … Read more

Overlapping Views in Android

Android handles transparency across views and drawables (including PNG images) natively, so the scenario you describe (a partially transparent ImageView in front of a Gallery) is certainly possible. If you’re having problems it may be related to either the layout or your image. I’ve replicated the layout you describe and successfully achieved the effect you’re … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)