Thursday, March 27, 2014

android controls dynamically add questions to ask you! ! ! !


XML file
android: id = "@ + id/m_frameLayout_01"
android: layout_width = "663dip"
android: layout_height = "108dip"
android: layout_marginLeft = "0dp"
android: layout_marginTop = "0dp">

android: id = "@ + id/m_imageview_luzi_b01"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: background = "@ drawable / android_bg" />
android: id = "@ + id/m_imageview_luzi_b01_1"
android: layout_width = "12dip"
android: layout_height = "12dip"
android: layout_marginTop = "2dp"
android: layout_marginLeft = "4dp"
android: background = "@ drawable/android_bg_1" />


FrameLayout layout has two ImageView, the second in the first above, but from the top with a little distance from the left
First fill the entire width and height
FrameLayout
XML comment out the second ImageView
Add a second ImageView
dynamic code in JAVAframelayout = (FrameLayout) findViewById (R.id.m_frameLayout_01);
LayoutParams params = new LayoutParams (2,4);
ImageView imageView = new ImageView (MainActivity.this);
params.height = 18;
params.width = 18;
params.leftMargin = 4;
params.topMargin = 2;
imageView.setBackgroundResource (R.drawable.android_bg_1);
imageView.setLayoutParams (params);
framelayout.addView (imageView);
You can add successfully, but leftMargin with topMargin parameters did not work, has not offset my
LayoutParams is android.widget.RelativeLayout.LayoutParams, to achieve the XML layout_marginTop how to set it
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
The RelativeLayout.LayoutParams replaced FrameLayout.LayoutParams
Reply:
cited a floor a_mean reply:
the RelativeLayout.LayoutParams replaced FrameLayout.LayoutParams

Well I try

Reply:
cited a floor a_mean reply:
the RelativeLayout.LayoutParams replaced FrameLayout.LayoutParams

Is that true, and it is not what the layout of the controls is what we should do LayoutParams parameters

No comments:

Post a Comment