我有一個相對的佈局,其中包含linearLayout
與兩個imageView
如下。android layout_centerInParent屬性以編程方式添加視圖後不工作
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/rlParent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:layout_centerInParent="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:layout_marginRight="5dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"/>
</LinearLayout>
</RelativeLayout>
,我已添加的自定義編程surfaceView
。加入後surfaceView
linearLayout
不在中心顯示。我試圖通過代碼設置layout_centerInParent
屬性,但它不起作用。
請幫幫我。
mPreview = new CustomSurfaceView(getActivity(),1, CameraPreview.LayoutMode.FitToParent, false,this);
LayoutParams previewLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
mLayout.addView(mPreview, 0, previewLayoutParams);
mLayout是Releativelayout和mPreview是定製surfaceview
你可以添加你的java代碼在哪裏你編程添加surfaceView? –
顯示如何以編程方式添加視圖 –
在LinearLayour或RelativeLayout中添加了'surfaceView'的位置? – FabioR