In a layout file I have the following :
    android:layout_width="100dp" 
    android:layout_height="wrap_content" android:layout_marginRight="10dp" 
    android:text="SYN" 
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:background="@drawable/rectanglepurple"
    android:textColor="#000000" 
    android:gravity="right"/>
I am attempting to achieve the following using code and so far I have :
Resources res = getResources();
Drawable drawable1=res.getDrawable(R.drawable.rectanglepurple);
TextView idText = new TextView(getActivity());
    idText.setText("SYN");
    idText.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium);
    idText.setTextColor(Color.BLACK);
    idText.setGravity(Gravity.RIGHT);
    idText.setBackgroundDrawable(drawable1);
I cant workout how to deal with
    android:layout_width="100dp" 
    android:layout_height="wrap_content" android:layout_marginRight="10dp" 
Any help appreciated.
 
     
     
    