无法将动态添加的按钮对齐到其父容器

时间:2019-02-18 15:31:49

标签: java android

我正在动态添加一个图像按钮,并尝试将其与父容器的右下角(在其内部)对齐,但该按钮位于容器的左上角(在其外部)

ImageButton Acceptbutton = new ImageButton(getContext());
Acceptbutton.setImageDrawable(getResources().getDrawable(R.drawable.accept));
Acceptbutton.setScaleType(ImageView.ScaleType.CENTER_CROP);
FrameLayout ll = getActivity().findViewById(R.id.imagecalibration);
Acceptbutton.setBottom(ll.getBottom());
Acceptbutton.setRight(ll.getRight());
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(100,100);
ll.addView(Acceptbutton, lp);

0 个答案:

没有答案