Android 安卓工作室:我可以’;t使按钮位于屏幕底部
我用红色标记了它应该是什么样子,我需要更改组件树的当前元素的属性,我不想删除它们或添加其他元素。 文本视图:Android 安卓工作室:我可以’;t使按钮位于屏幕底部,android,android-layout,android-studio,user-interface,layout,Android,Android Layout,Android Studio,User Interface,Layout,我用红色标记了它应该是什么样子,我需要更改组件树的当前元素的属性,我不想删除它们或添加其他元素。 文本视图: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/topLayout" android:layout_width="match_p
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true">
<com.camera.test.ui.camera.CameraSourcePreview
android:id="@+id/preview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.camera.test.ui.camera.GraphicOverlay
android:id="@+id/graphicOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:id="@+id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/footer"
android:gravity="center">
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:background="@drawable/icon"
android:onClick="Categories"
android:text="BUTTON"
android:textColor="#228496"
android:textSize="21sp" />
</RelativeLayout>
</com.camera.test.ui.camera.CameraSourcePreview>
</LinearLayout>
为什么使用水平线性布局作为顶层。 可以将相对布局用作顶层,也可以在内部相对布局中添加特性 android:layout\u alignParentBottom=“true”
为什么使用水平线性布局作为顶层。 可以将相对布局用作顶层,也可以在内部相对布局中添加特性 android:layout\u alignParentBottom=“true”
如果要在屏幕下方提供按钮,则使用相对布局作为父级,并提供属性alignparentbottom,如果坚持使用LinearLayout作为父级,则使用此
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="bottom|center_horizontal"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"/>
</LinearLayout>
如果要在屏幕下方提供一个按钮,则使用相对布局作为父级,并提供属性alignparentbottom,如果坚持使用LinearLayout作为父级,则使用该属性
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="bottom|center_horizontal"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"/>
</LinearLayout>
您是否已将此项目导入android studio或已更新android studio?我建议您了解LinearLayout、RelativeLayout和ConstraintLayout之间的区别。@Wahdat Kshimi我更改了当前打开的项目,无论如何,已经有了很好的答案。您是否已将此项目导入android studio或更新了android studio?我建议您了解LinearLayout、RelativeLayout和ConstraintLayout之间的区别。@Wahdat Kshimi我更改了当前打开的项目,无论如何,已经有了很好的答案。