How do I define by code the attribute of view?
For example, how can I define this image button with this attribute (width, height, margin top, etc)?
<ImageButton
android:id="@+id/add_butt1"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginTop="50dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/button_state"
/>
If you are talking about layout_ attributes – than it can be defined with LayoutParams inner class of the layout, in which you want to add your view. For example you can use this: http://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams.html if you will add your view to RelativeLayout.