gpt4 book ai didi

java - 有没有一种简单的方法可以将按钮添加到子 Activity 的操作栏?

转载 作者:太空宇宙 更新时间:2023-11-03 13:39:31 26 4
gpt4 key购买 nike

我正在尝试将按钮添加到 android studio 应用程序中的操作栏到子 Activity ,但我只能设法将其添加到主要 Activity 。有人知道我该怎么做吗?

我希望“确定”按钮位于我用橙色绘制的位置。

带有操作栏的主要 Activity 。 main activity with action bar

带操作栏的子 Activity child activity with action bar

最佳答案

您不必使用操作栏。您只能使用您想要的背景颜色的 View 。在您将按钮设置在彩色区域上方之后。

在 Android Studio 中:

值(value)观>风格

使用这个:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

代替

 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

回到你的布局:

// Change your background with LinearLayout's background propoerty
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"

android:background="#FFA908"


>


// You can put here whatever you want. İf you wish image or button.



<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Example"
android:layout_gravity="center"
android:layout_marginLeft="200dp"
/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Example"
android:layout_gravity="center"
/>



</LinearLayout>

İf 你可以像这样使用。您不需要使用操作栏。您可以轻松创建任何您想要的内容。

关于java - 有没有一种简单的方法可以将按钮添加到子 Activity 的操作栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56894237/

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