我想把照片放在FrameLayout或LinearLayout中,所以当我用相机拍照时,照片应该放在另一个下面。
问题是,我只能添加一张图片。第二个错误出现如下错误:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=131074, result=-1, data=null} to activity {com.unitnode/com.unitnode.OpenprojectAlternative}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.这是我的布局文件:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/openproctScrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#FFFFFF"
android:fillViewport="true"
android:padding="15dp">
<FrameLayout
android:id="@+id/pictureTabLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="@+id/neuesBildButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/addtabbutton" />
</FrameLayout>
</ScrollView>为此,我首先用:ImageView:imageView = new ImageView(this.getActivity())创建一个新对象,并设置如下:imageView.setAdjustViewBounds(true);
在此之后,我将图像设置为ImageView,设置高度并将ImageView添加到布局中:
imageView.setMaxHeight(createScaleBitmap.getHeight());
Log.d("bmRotated.getHeight()", "bmRotated.getHeight() " + createScaleBitmap.getHeight());
imageView.setImageBitmap(createScaleBitmap);
FrameLayout.LayoutParams viewParameters = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
viewGroup.addView(imageView, viewParameters);编辑:我每次都尝试创建一个新的LinearLayout。但是结果是一样的(我甚至不能再添加一张图片了):
布局=新的LinearLayout(this.getActivity());
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layout.setLayoutParams(layoutParams);
viewGroup.addView(layout);
layout.addView(imageView);其中viewGroup是LinearLayout
发布于 2014-10-12 09:36:23
您只添加了一个框架输出。“要存储的图片的framelayout=number数。”因此,当您想要存储图片,附加到框架,并使它不可见,并使另一个帧可见,然后再运行意图。向我查询进一步的帮助。
发布于 2014-10-12 10:22:13
如果将多个图像添加到FrameLayout中,它们将被有效地堆叠,并且只会在堆栈的顶部看到图像。
这是你想要的吗?
如果您想一个接一个地显示并滚动它们(因为您使用的是ScrollView),那么您应该考虑使用GridView或ListView,并将图像添加到适配器中。
https://stackoverflow.com/questions/26323480
复制相似问题