Place view inside FrameLayout in Android

前端 未结 5 1291
再見小時候
再見小時候 2020-12-31 17:41

I want to add a view inside a FrameLayout programmatically and to place it in a specific point within the layout with a specific width and height. Does FrameLayout support t

5条回答
  •  -上瘾入骨i
    2020-12-31 18:04

    The thread here on stackOverflow at

    How do you setLayoutParams() for an ImageView?

    covers it somewhat.

    For instance: LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(30, 30); yourImageView.setLayoutParams(layoutParams);

    implies that you need to be defining a LinearLayout.LayoutParams (or in your case a FrameLayout.layoutParams) object to pass to the setLayoutParams method of your v object.

    At

    http://developer.android.com/reference/android/widget/FrameLayout.html

    it almost makes it looks like you could ask your v to:

    generateDefaultLayoutParams () via this method if you have not defined the parameters specifically.

    But it's late, and those links are making my eyes bleed a little. Let me know if they nhelp any :-)

提交回复
热议问题