布局标记用于关于对象相对于包含元素的放置,对齐和对齐的问题。有关CSS的问题,请改用“css”标签。
我传递的容器颜色没有包裹MediumTopAppBar的标题
这是它的样子 脚手架( 顶部栏 = { 中顶部应用栏( 颜色 = TopAppBarDefaults.mediumTopAppBarColors( 容器颜色 = Color.Yell...
为什么我的Android自定义KeyboardView在设置新键盘后会溢出?
我正在开发Android键盘。现在我想将键盘从字母更改为符号,然后用户按“123”按钮。 我的问题是,调用后键盘溢出
如何在 Flutter 中的“POMODONE”下方添加文字?
我正在尝试修改我的 Flutter 布局以在“POMODONE”文本下方显示另一段文本。这是我想要实现的目标的视觉表示: 目前,我的布局看起来...
我试图在同一行中获取三个 div,作为它们下面以文本为中心的三个图像的标题。我可以左右移动去工作,但是中间的那个不行……
如何在不同的 Activity 中的工具栏上添加不同的按钮?
这是我的activity_main.xml,它有一个基本的工具栏和右侧的两个按钮(以及一个导航视图): 这是我的 activity_main.xml,它有一个基本的 Toolbar 和右侧的两个 Button(还有一个 NavigationView): <?xml version="1.0" encoding="utf-8"?> <androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/mxhbg" android:id="@+id/drawer_layout" android:fitsSystemWindows="true" tools:context="com.myapp.MainActivity" tools:openDrawer="start"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/mxhbg" android:orientation="vertical" android:keepScreenOn="true" android:weightSum="10"> <LinearLayout android:layout_width="match_parent" android:layout_height="54dp" android:orientation="horizontal"> <androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@color/colorPrimary" android:elevation="4dp" android:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <Button android:id="@+id/btnRandom" android:layout_width="30dp" android:layout_height="30dp" android:layout_alignParentEnd="true" android:layout_centerVertical="true" android:layout_gravity="end" android:layout_marginEnd="16dp" android:background="@drawable/ic_shuffle"> </Button> <Button android:id="@+id/btnRescanSongs" android:layout_width="30dp" android:layout_height="30dp" android:layout_alignParentEnd="true" android:layout_centerVertical="true" android:layout_gravity="end" android:layout_marginEnd="16dp" android:background="@android:drawable/stat_notify_sync"> </Button> </androidx.appcompat.widget.Toolbar> </LinearLayout> // other stuff </LinearLayout> <com.google.android.material.navigation.NavigationView android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:id="@+id/nav_view" app:headerLayout="@layout/nav_header" app:menu="@menu/drawer_menu"> </com.google.android.material.navigation.NavigationView> </androidx.drawerlayout.widget.DrawerLayout> 我这样在MainActivity上设置它: setContentView(R.layout.activity_main); toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); 现在,在另一个 Activity (SyncActivity) 上,我想显示相同的 Toolbar,但右侧有不同的图标。 正确的做法是什么? 在activity_sync.xml上执行此操作: <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/mxhbg" tools:context=".SyncActivity"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/mxhbg" android:orientation="vertical" android:keepScreenOn="true" android:weightSum="10"> <LinearLayout android:layout_width="match_parent" android:layout_height="54dp" android:orientation="horizontal"> <androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@color/colorPrimary" android:elevation="4dp" android:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <Button android:id="@+id/btnRescanSongs" android:layout_width="30dp" android:layout_height="30dp" android:layout_alignParentEnd="true" android:layout_centerVertical="true" android:layout_gravity="end" android:layout_marginEnd="16dp" android:background="@android:drawable/stat_notify_sync"> </Button> </androidx.appcompat.widget.Toolbar> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="9"> <ListView android:id="@+id/log" android:layout_width="match_parent" android:layout_height="match_parent" android:divider="@android:color/transparent" android:dividerHeight="10.0sp" android:padding="8dp"> </ListView> </LinearLayout> </LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout> 以及 SyncActivity: setContentView(R.layout.activity_sync); Objects.requireNonNull(getSupportActionBar()).setTitle("Sync"); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); 它在主要的下方添加了一个新的 Toolbar。 另外:为什么主Toolbar上的图标没有显示在其他活动上?看来是把他们藏起来了?为什么? 您可以从布局 xml 中删除所有工具栏按钮并将它们移动到菜单 xml 中。 文件:res/menu/yourmenuname.xml <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/menu_rescan_songs" android:icon="@android:drawable/stat_notify_sync" android:title="@string/menu_rescan_songs" app:showAsAction="always"/> </menu> 请注意,您还必须提供标题,而不仅仅是图标,您可以使用 showAsAction 与 always 来始终显示图标,或者 ifRoom 或 ifRoom|withText 只是尝试您最喜欢的内容。 然后你覆盖这个函数并加载你的菜单 @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.yourmenuname,menu); return super.onCreateOptionsMenu(menu); } 要处理菜单操作,请使用: @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.menu_rescan_songs: doSomething(); return true; // case R.id.action_settings: // in case you need an extra button on // startSettings(); // on this activity // return true; default: return super.onOptionsItemSelected(item); } } 您可以使用菜单做很多事情,在这里添加一些链接可以帮助您继续阅读它们: https://developer.android.com/guide/topics/resources/menu-resource https://developer.android.com/guide/fragments/appbar
如何使用 DIV 对 Flexbox 项目进行分组,但不影响布局,就好像 DIV 不存在一样?
我在 Flexbox 容器中有多个项目,我已经实现了所需的布局行为(考虑到 .tool-body 可以动态隐藏/显示)。 以下html: 我在 Flexbox 容器中有多个项目,我已经实现了所需的布局行为(考虑到 .tool-body 可以动态隐藏/显示)。 以下html: <div class="root"> <div class="toolbar">toolbar1</div> <div class="tool-body">body1</div> <div class="toolbar">toolbar2</div> <div class="tool-body">body2</div> <div class="toolbar">toolbar3</div> <div class="tool-body">body3</div> </div> 使用CSS: .root { display: flex; flex-direction: column; height: 100%; width: 100%; } .tool-body { flex: 1 1 100%; } 现在,出于应用程序逻辑的目的,我想用 <div> 包装这些项目,以便在应用程序的其他方面拥有更简单的逻辑,例如: 键盘、鼠标事件(冒泡) $(".my-group").mousemove(...) //...enter/leave jQuery DOM 遍历用例 $(this).closest(".my-group")... //more chained calls 基于嵌套元素焦点的css .my-group:has(:focus) { /* background/border stuff*/ } 所以,我希望 html 看起来像这样: <div class="root"> <div class="my-group"> <div class="toolbar">toolbar1</div> <div class="tool-body">body1</div> </div> <div class="my-group"> <div class="toolbar">toolbar2</div> <div class="tool-body">body2</div> </div> <div class="my-group"> <div class="toolbar">toolbar3</div> <div class="tool-body">body3</div> </div> </div> ...加上额外的 css .my-group: .my-group { display: flex; flex-direction: column; flex: 1 0 auto; /* tried-out many combinations of grow/shrink/basis */ } 但是现在,布局行为不一样了,因为容器现在 .root 容器有 3 个项目,它们本身就是嵌套的 Flex 容器。 我知道 Flex 通过容器工作,因为父元素有一些定义的方向,直接子元素是根据其 flex-(grow|shrink|basis) 进行布局计算的项目。 我不确定是否有可能给出 html 结构,但该布局的行为就好像 <div class="my-group"> 根本不存在一样。 正如我所说,这个额外的 div 包装是为了简化其他方面,如果我不能这样做,其他方面往往会变得非常复杂。 这里是 JSFIDDLE,它并排演示了我的示例: https://jsfiddle.net/tqrn1z0s/4/ 鉴于: 可能有 1 到 4 个这样的 .my-groups 布局行为应该是这样的 当显示所有 .tool-body-es 时,垂直空间应为每个 .my-group 均匀分配 当某些 .tool-body-es 被隐藏时,显示其相应的 .toolbar,其余垂直空间均匀分布在显示的其他空间中。 问题: 如何实现第二个 html 的布局行为以充当第一个 html。 是否可以告诉浏览器以下内容:出于布局目的,假装<div class="my-group">不存在 还有其他解决方法吗? 要让浏览器忽略 .my-group,那么您可以在其上使用 display: contents(请参阅有关 css 技巧的解释)。它基本上使 .my-group 的孩子看起来就像是 .root 的孩子。使用它有一些注意事项(请参阅caniuse.com),但如果您超出了这些限制,那么您应该很好。 .root { display: flex; flex-direction: column; height: 100%; width: 100%; } .tool-body { flex: 1 1 100%; } .my-group { display: contents; } <div class="root"> <div class="my-group"> <div class="toolbar">toolbar1</div> <div class="tool-body">body1</div> </div> <div class="my-group"> <div class="toolbar">toolbar2</div> <div class="tool-body">body2</div> </div> <div class="my-group"> <div class="toolbar">toolbar3</div> <div class="tool-body">body3</div> </div> </div>
如何在 Flutter 中的主 AppBar 下方添加第二个 AppBar?
我的目标是创建一个 Flutter 布局,其中两个 AppBar 彼此堆叠,类似于此设计: 目前,我的布局如下所示: 我的代码: HomePageTimerUI 类扩展了无状态...
如何修复 Flutter 中的“RenderObject 无限大小”布局错误?
我在 Flutter 布局中遇到以下错误: ======== 渲染库捕获异常====================================== ================ 抛出以下断言...
我对 HTML、CSS 还很陌生,我想知道这个布局是否可以实现这个布局。 我想要的结果 我尝试过使用 shape-outside 属性。但结果已经出来了...
如何在 Flutter 中均匀分布 RichText Widget 中的图标和文本?
我正在使用 Dart 开发 Flutter 应用程序,并且遇到了特定的 UI 设计挑战。我的目标是实现一种布局,其中图标和文本在 RichText 小部件中均匀分布。 ...
首页 卡片 https://www.figma.com/file/qTJ3JFiQJXA61RP5M7X33X/UIFresh-quiz-app-ui?type=design&node-id=0%3A1&mode=design&t=07jmS1hejheKTdqq-1 我正在创建一个测验应用程序作为后端...
seaborn 的散点图产生带有小白边框的点。如果有一些重叠的点,这很有帮助,但一旦有很多重叠的点,它就会在视觉上变得嘈杂。怎么会...
当 javafx 中发生操作时,如何更改分割窗格的一半,同时保持另一半不变
我正在尝试在 javaFX 中创建一个应用程序,它有两个主要部分。一侧有一组按钮或控件,另一侧显示每个按钮或控件的一组不同数据
修复 Flutter ToDo 应用中的 RenderFlex 溢出错误
我正在使用 Flutter 开发一个 ToDo 应用程序,并遇到了 RenderFlex 溢出错误,我正在努力解决该错误。调试控制台提供了以下输出,表明内容...
我一直在为我的一个大学课程开发一个网站,我们刚刚进入课程的样式部分,我不知道如何将图像与诸如
如何知道应用程序是否位于nextjs 14应用程序路由器中的未找到页面上
我在确定我的 Next.js 应用程序是否位于应用程序路由器内的 404 未找到页面上时遇到困难。我有一个正常运行的 404 未找到页面,当 URL 不匹配时会显示...
我在测试我的应用程序时遇到了问题,一切都运行良好,直到我打开个人热点并且蓝色条出现在顶部,所有标签和按钮都向下移动...
useRef.current 由于在 useAnimatedStyle 中访问而无法在 onLayout 回调中工作
在尝试制作一个可扩展组件时,当点击时,它会通过动画扩展至动态高度,我遇到了这种奇怪的行为,其中 useRef 对象不会更新。 const contentHe...
是否有一种动态方法可以获取当前设置为我的 Activity 的 XML 中的根布局(所有其他布局的父布局)? 我所追求的不是给我的根布局一个
我的问题是我的导航抽屉工具栏隐藏在配置文件活动的装饰后面。我仔细研究了这样的问题,我得到的唯一可能的解决方案是改变构造......