Buggy code:
public class TestFragment4 extends Fragment { private static final String ARG_PARAM1 = "param1" ; private static final String ARG_PARAM2 = "param2" ; private String mParam1 ; private String mParam2 ; Bundle args ; FragmentManager manager ; Fragment mFragment ; String [ ] sharok ; String [ ] subject ; String [ ] pdfUrl ; Button village_protection ; Button village_modification ; private TestFragment4 . OnFragmentInteractionListener mListener ; public static TestFragment4 newInstance ( String param1 , String param2 ) { } public TestFragment4 ( ) { } @ Override public void onCreate ( Bundle savedInstanceState ) { } @ Override public View onCreateView ( LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) { View view = inflater . inflate ( fragment_test_fragment4 , container , false ) ; args = new Bundle ( ) ; manager = getFragmentManager ( ) ; mFragment = new PDFFragment ( ) ; village_protection = ( ( Button ) ( view . findViewById ( button1 ) ) ) ; village_protection . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { args . putString ( "URL" , "https:////docs.google.com//gview?embedded=true&url=http:////modmr.portal.gov.bd//sites//default//files//files//modmr.portal.gov.bd//files//cd235cf2_852d_4fb3_9874_9805d5ea976e//TR%20implementation%20Guideline%202014.pdf" ) ; mFragment . setArguments ( args ) ; manager . beginTransaction ( ) . replace ( content_frame , mFragment ) . addToBackStack ( mFragment . toString ( ) ) . commit ( ) ; } } ) ; village_modification = ( ( Button ) ( view . findViewById ( button2 ) ) ) ; village_modification . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { args . putString ( "URL" , "https:////docs.google.com//gview?embedded=true&url=http:////modmr.portal.gov.bd//sites//default//files//files//modmr.portal.gov.bd//files//efcd85a7_59f2_4b22_8f9b_7e6397d83e17//FFW%20Guideline%202014.pdf" ) ; mFragment . setArguments ( args ) ; manager . beginTransaction ( ) . replace ( content_frame , mFragment ) . addToBackStack ( mFragment . toString ( ) ) . commit ( ) ; } } ) ; LinearLayout ll = ( ( LinearLayout ) ( view . findViewById ( relief_layout ) ) ) ; sharok = getResources ( ) . getStringArray ( sharok_no ) ; pdfUrl = getResources ( ) . getStringArray ( relief_urls ) ; for ( int i = 0 ; i < ( sharok . length ) ; i ++ ) { final int j = i ; LinearLayout innerLayout = new LinearLayout ( getActivity ( ) ) ; LinearLayout . LayoutParams params = new LinearLayout . LayoutParams ( LayoutParams . MATCH_PARENT , LayoutParams . WRAP_CONTENT ) ; int dpValue = 20 ; float d = getResources ( ) . getDisplayMetrics ( ) . density ; int margin = ( ( int ) ( dpValue * d ) ) ; params . setMargins ( margin , 0 , margin , margin ) ; innerLayout . setGravity ( TOP ) ; innerLayout . setLayoutParams ( params ) ; innerLayout . setOrientation ( HORIZONTAL ) ; innerLayout . setBackgroundDrawable ( getResources ( ) . getDrawable ( layout_bg ) ) ; innerLayout . setPadding ( margin , margin , margin , margin ) ; LinearLayout . LayoutParams params1 = new LinearLayout . LayoutParams ( LayoutParams . WRAP_CONTENT , LayoutParams . WRAP_CONTENT ) ; params1 . setMargins ( 0 , 0 , margin , 0 ) ; ImageButton btn = new ImageButton ( getActivity ( ) ) ; btn . setImageResource ( pdf_icon ) ; btn . setBackgroundDrawable ( getResources ( ) . getDrawable ( textview_bg ) ) ; btn . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { if ( j == 0 ) { args . putString ( "URL" , ( "https:////docs.google.com//gview?embedded=true&url=" + ( pdfUrl [ j ] . toString ( ) ) ) ) ; } else { args . putString ( "URL" , pdfUrl [ j ] . toString ( ) ) ; } mFragment . setArguments ( args ) ; manager . beginTransaction ( ) . replace ( content_frame , mFragment ) . addToBackStack ( mFragment . toString ( ) ) . commit ( ) ; } } ) ; innerLayout . addView ( btn , params1 ) ; TextView tv1 = new TextView ( container . getContext ( ) ) ; tv1 . setText ( sharok [ i ] ) ; tv1 . setTextColor ( getResources ( ) . getColor ( text_color ) ) ; <START_BUG> tv1 . setTextSize ( COMPLEX_UNIT_DIP , 16 ) ; <END_BUG> innerLayout . addView ( tv1 ) ; ll . addView ( innerLayout ) ; } return view ; } public void onButtonPressed ( Uri uri ) { } @ Override public void onAttach ( Activity activity ) { } @ Override public void onDetach ( ) { } public interface OnFragmentInteractionListener { public void onFragmentInteraction ( Uri uri ) { } } }

Fix:
tv1 . setTextSize ( COMPLEX_UNIT_DIP , 18 ) ;