gpt4 book ai didi

android - SurfaceView Inflate Button 在纵向底部居中

转载 作者:行者123 更新时间:2023-11-29 14:16:06 29 4
gpt4 key购买 nike

我正在推出我自己的相机应用程序,为此我使用的是横向方向作为标准的 SurfaceView。

我正在尝试做的是,使 SurfaceView 膨胀以具有一个按钮。但我希望按钮显示在纵向底部的中央,就像大多数相机应用程序一样。我正在膨胀的按钮布局如下,我不确定哪种控件组合会给我想要的结果。

我的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="right"
>
<Button
android:id="@+id/takepicture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" * Take Picture "
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="10px"
/>
</LinearLayout>

感谢您的帮助! =]

最佳答案

玩转 layout_weight。试试这个:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="right"
>
<com.YOURSurfaceView android:layout_width="fill_parent" android:background="#ff0" android:layout_weight=".2"
android:layout_height="fill_parent" >

</com.YOURSurfaceView>
<Button
android:id="@+id/takepicture"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text=" * Take Picture "
android:layout_weight="1"
android:layout_margin="10px"
/>
</LinearLayout>

关于android - SurfaceView Inflate Button 在纵向底部居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10875984/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com