Without seeing your code, it is virtually impossible to really help. However, that being said, I took the code from the site, ran it, and it looks good to me. One thing I did find interesting though, is that his code doesn't specify which type of LayoutParams he is creating, which means he has an import statement that he isn't showing. Here is my modified version of the code, which places the textviews in the correct place on the screen:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Initializing imageView ImageView imageView = new ImageView(this); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); //Ignore the reference to btn_radio below... just threw it in to get something to compile imageView.setImageResource(android.R.drawable.btn_radio); imageView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); TextView textView1 = new TextView(this); textView1.setText("Fanny Hands Lane, London"); textView1.setTextSize(22); textView1.setGravity(Gravity.CENTER_HORIZONTAL); textView1.setTextColor(Color.parseColor("#fcfcfc")); textView1.setBackgroundColor((Color.parseColor("#00000c"))); textView1.setPadding(10,10,10,10); FrameLayout.LayoutParams lp1 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL); lp1.setMargins(0,20,0,0); textView1.setLayoutParams(lp1); TextView textView2 = new TextView(this); textView2.setTextSize(18); textView2.setGravity(Gravity.RIGHT|Gravity.BOTTOM); textView2.setText("26/Jan/2014"); textView2.setTextColor(Color.WHITE); textView2.setPadding(10,10,10,10); textView2.setBackgroundColor(Color.BLACK); FrameLayout.LayoutParams lp2 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM|Gravity.RIGHT); textView2.setLayoutParams(lp2); //Initializing frame layout FrameLayout framelayout = new FrameLayout(this); framelayout.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); //Adding views to FrameLayout framelayout.addView(imageView); framelayout.addView(textView1); framelayout.addView(textView2); setContentView(framelayout); } Hope that helps, Justin On Sat, Jan 16, 2016 at 7:11 AM mr010rm <u...@wp.pl> wrote: > I tested "Creating FrameLayout Programmatically" from > http://javatechig.com/android/android-framelayout-example > > and I have bad result > Text 1 and Text2 is position from left and top corner. Why? > > All other attempts have failed deployment. > The effect is always the same > > > -- > You received this message because you are subscribed to the Google Groups > "Android Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to android-developers+unsubscr...@googlegroups.com. > To post to this group, send email to android-developers@googlegroups.com. > Visit this group at https://groups.google.com/group/android-developers. > To view this discussion on the web visit > https://groups.google.com/d/msgid/android-developers/64031f07-b5f1-4e77-928c-2d8204bf399c%40googlegroups.com > <https://groups.google.com/d/msgid/android-developers/64031f07-b5f1-4e77-928c-2d8204bf399c%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/CAOq06s89Z%2BZVsTrs82eq9Y5-7aWOiGabht1sU%2BCY5ezUvQCOrQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.