我有以下LinearLayout
,其中包含相机源预览,并在相机预览顶部绘制覆盖。预览是全屏。Android:防止ImageButton覆盖屏幕?
现在,当我尝试添加一个ImageButton
来切换正在使用的设备摄像头(前/后)时,我无法阻止该按钮显示全屏,完全覆盖了摄像头预览。我只是希望这个按钮的大小适中,坐在角落,覆盖相机预览,这样用户可以按下它来更改显示的相机预览到前置或后置相机。
我试过阅读Layouts documentation,按钮和几个教程,但我的按钮似乎不响应我更改的任何属性。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true">
<foo.bar.ui.camera.CameraSourcePreview
android:id="@+id/preview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:layout_width="48dp"
android:layout_height="48dp"
android:id="@+id/switch_camera"
android:src="@drawable/ic_switch_camera_black_48dp"
android:paddingLeft="16dp"
android:paddingBottom="16dp"
android:clickable="true"
android:contentDescription="@string/switch_camera"
android:baselineAlignBottom="false" />
<foo.bar.ui.camera.GraphicOverlay
android:id="@+id/faceOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</foo.bar.ui.camera.CameraSourcePreview>
</LinearLayout>
如果你希望它被覆盖,检查出[FrameLayout里(http://developer.android.com/reference/ Android设备/部件/ FrameLayout.html)。 –
谢谢,我能够找到http://stackoverflow.com/questions/29072946/how-do-i-create-overlay-button-in-my-android-layout这帮助我了解不同组件之间的关系在我的布局。 –
太棒了,很高兴你明白了。 –