我有一个带摄像头的小应用程序,我有一个设备,这不是问题,但如果我可以更改该应用程序,将会在美学上有很大改进。
我放了 Activity 的xml代码:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/layout">
<FrameLayout
android:id="@+id/preview"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="0dip">
</FrameLayout>
<Button
android:id="@+id/buttonClick"
android:layout_width="109dp"
android:layout_height="105dp"
android:layout_gravity="center"
android:background="@drawable/obutrador2" >
</Button>
</LinearLayout>
当我运行应用程序时,按钮占据的整个屏幕高度上有一条白色条纹。我该如何解决这个问题?它会使按钮显示在相机正在拍摄的图像上方,作为具有默认手机的应用程序。
问题是如何定位框架布局,使其充满屏幕并将按钮置于底部中心。如果我让 FrameLayout 全屏显示,按钮就会消失。
我留下了一张照片的链接: https://www.dropbox.com/s/jbns8jddtwxjhdp/IMAG0348.jpg
最佳答案
我认为您应该像这样在 FrameLayout 中定义 Button。 您可以将 FrameLayout 作为父布局,并且可以将按钮放在任何您想要的地方
<FrameLayout
android:id="@+id/preview"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/buttonClick"
android:layout_width="109dp"
android:layout_height="105dp"
android:layout_gravity="center"
android:background="@drawable/obutrador2" >
</Button>
</FrameLayout>
希望这对你有用...谢谢
关于android - 在 frameLayout 中放置一个按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15035866/