布局定义用户界面的可视结构,例如活动,片段或应用程序窗口小部件的UI。
实现新 API SplashScreen 后 DialogFragment 的边距/填充问题
我在我的应用程序上添加了新的 Splashscreen API (androidx.core:core-splashscreen:1.0.0-rc01),之后我的边距/填充被破坏,但仅适用于我的启动器活动 (MainActivity),特别是对于 di.. .
LinearLayout 不显示所有 ListView,只显示一个孩子
我有一些数据将显示在 ListView 中。问题是一切都很顺利,但 ListView 或 LinearLayout 没有足够的扩展来显示 CustomListV 的所有子项...
我试图在执行api请求时显示视图布局,它是xml布局,并在请求完成后将其删除,布局包含TextView和动画,并且在布局显示后我...
资源$NotFoundException - 资源 ID #<address>
我在许多不同的设备上面临着很多有关 Resoures$NotFoundException 的问题。我无法使用我的 Samsung A50(Android v11、One UI v3.1)和 Nexus 5(Android v...
我正在创建一个扩展 MaterialButton 的自定义按钮 MyButton。用例是按钮有大和小 2 种尺寸,大按钮将是全宽(类似于 match_parent)并且 s...
我有一个问题,如何在 android studio 中调整背景图像的大小以匹配整个布局,例如: 我有一个默认为横向的可绘制对象,但我的布局是水平的,我想要
在此处输入图像描述我已经在 android studio 中以 XML 创建了一个报告布局。单击布局上的“生成”按钮后,我需要将布局转换为 PDF 格式。有没有
我正在创建一个扩展 MaterialButton 的自定义按钮 MyButton。用例是按钮有大和小 2 种尺寸,大按钮将是全宽(类似于 match_parent)并且 s...
我正在开发实时设备到Android中的服务器流媒体。我能够在服务器上以字节为单位发送数据,但是当我在服务器 VLC 上录制期间播放该文件时,会说找不到 MOOV 原子。经过...
如何更改 Material 3 android xml 的警报对话框的颜色
我想更改材质3警报对话框的容器颜色 我尝试使用官方文档中的内容 但我无法更改颜色,容器的背景颜色仍然是粉红色/紫色 ...
为什么我的DialogFragment在Android 11中没有全屏显示?
我有一个对话框片段,用于从列表中进行选择。我在全屏模式下有这个,它在 11/ API 30 之前一直有效。但是,现在在 11 中,它开始出现经典的“不...
假设我正在我的应用程序中制作新闻布局。第一个 ImageView 应该是主要的,这就是为什么它较大的 ImageView 和其他新闻将由较小的 ImageView 呈现。 所以每条新闻都有图像...
我有一个视图,我想在其上放置两个 ListView,这两个 ListView 的位置根据屏幕方向彼此相邻。它看起来像这样: 横屏方向:
我设计了一个工具栏,但它不允许我制作匹配父级布局。它的左侧被锁定,不允许我将 TextView 放在那里,但右侧表现良好; 我看过...
Textcell 在模拟器上显示,但在 Android 上不显示
我的 xaml 在模拟器中正确显示时遇到问题,但在打包并安装到我的 Android 手机上时却出现问题。另外,堆栈布局中的普通标签根本不会显示在我的
BottomSheetDialog 与 EditText(删除键盘下的背景)
我有一个 BottomSheetDialog,用作评论部分。在它的底部,有一个 EditText 视图,使用户能够添加新评论。 当键盘出现时,问题就出现了——du...
我为我的应用程序创建了一个深层链接,myapp://video 或者说我还添加了 uber:// 但是当我从 Chrome 浏览器打开这些链接时,它会带我去谷歌,它不会将此视为一个链接,那么如何...
我的布局如下: 我的布局如下: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/textView1" style="@style/behindMenuItemLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:text="Twitter Feeds" android:textStyle="bold" /> <ListView android:id="@+id/list" android:layout_width="350dp" android:layout_height="50dp" /> <TextView android:id="@+id/textView1" style="@style/behindMenuItemLabel1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="1dp" android:text="FaceBook Feeds" /> <ListView android:id="@+id/list1" android:layout_width="350dp" android:layout_height="50dp" /> </LinearLayout> 我的要求是在TextView和ListView之间画一条水平线 有人可以帮忙吗? 它将在 TextView 和 ListView 之间绘制银灰色线 <TextView android:id="@+id/textView1" style="@style/behindMenuItemLabel1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="1dp" android:text="FaceBook Feeds" /> <View android:layout_width="match_parent" android:layout_height="2dp" android:background="#c0c0c0"/> <ListView android:id="@+id/list1" android:layout_width="350dp" android:layout_height="50dp" /> 您应该使用新的轻量级视图Space来绘制分隔线。 如果您使用 Space 而不是 View,您的布局加载速度会更快。 水平分隔线: <android.support.v4.widget.Space android:layout_height="1dp" android:layout_width="match_parent" /> 垂直分隔线: <android.support.v4.widget.Space android:layout_height="match_parent" android:layout_width="1dp" /> 您还可以添加背景: <android.support.v4.widget.Space android:layout_height="match_parent" android:layout_width="1dp" android:background="?android:attr/listDivider"/> 使用示例: .... <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="One"/> <android.support.v4.widget.Space android:layout_height="match_parent" android:layout_width="1dp" android:background="?android:attr/listDivider"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Two"/> <android.support.v4.widget.Space android:layout_height="match_parent" android:layout_width="1dp" android:background="?android:attr/listDivider"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Three"/> .... 为了使用Space,您应该在build.gradle中添加依赖项: dependencies { compile 'com.android.support:support-v4:22.1.+' } 文档https://developer.android.com/reference/android/support/v4/widget/Space.html 在布局中要分离的视图之间添加类似的内容: <View android:id="@+id/SplitLine_hor1" android:layout_width="match_parent" android:layout_height= "2dp" android:background="@color/gray" /> 希望有帮助:) 创建一次并在需要的地方使用它是一个好主意。 将其添加到您的 styles.xml 中: <style name="Divider"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">1dp</item> <item name="android:background">?android:attr/listDivider</item> </style> 并将其添加到需要行分隔符的 xml 代码中: <View style="@style/Divider"/> 最初由 toddles_fp 回答这个问题:Android Drawing Separator/Divider Line in Layout? 试试这个 <View android:layout_width="match_parent" android:layout_height="2dp" android:background="?android:attr/listDivider"/> 多年之后,终于有一个合适的视图可以在 XML 布局上显示分隔符/分隔线/水平线。为 Android 开发 Material Components 的团队已发布版本 1.5.0-alpha01,其中添加了 MaterialDivider 类。这允许向布局添加分隔线,如前所述。 首先,在 build.gradle 中添加以下内容: implementation 'com.google.android.material:material:1.5.0-alpha01' 然后,在 XML 布局上您可以编写: <com.google.android.material.divider.MaterialDivider android:layout_width="match_parent" android:layout_height="wrap_content"/> 瞧,你有一个分隔器。如果你想自定义分隔线的颜色,有一个xml属性:app:dividerColor。此视图还允许通过样式设置主题。欲了解更多信息,您可以查看此链接。 <View android:id="@+id/view" android:layout_width="match_parent" android:layout_height="2dp" android:background="#000000" /> 对 Bhoomika 接受的答案进行了改进,以获得更精美的外观: <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@android:color/black" android:alpha="0.1"/> android:alpha 用于设置视图的不透明度。 您可以将此视图放在您的视图之间来模仿线条 <View android:layout_width="fill_parent" android:layout_height="2dp" android:background="#c0c0c0"/> 试试这个对我有用 <View android:layout_width="1dp" android:layout_height="match_parent" android:background="@color/tw_composer" /> 创建水平线 如果您正在使用 TextView,然后您想放置一行,则使用 View 这样你就可以使用任何颜色,如蓝色、红色或黑色提及背景颜色。 <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@android:color/black"></view> 在您希望组件之间有分隔线的每个父级 LinearLayout 中,添加 android:divider="?android:dividerHorizontal" 或 android:divider="?android:dividerVertical。 根据您的LinearLayout的方向在它们之间选择合适的。 据我所知,这个资源样式是从Android 4.3开始添加的。 试试这个 <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@android:color/darker_gray"/> ---->简单的一个 <TextView android:layout_width="match_parent" android:layout_height="1dp" android:background="#c0c0c0" android:id="@+id/your_id" android:layout_marginTop="160dp" /> 可以指定背景颜色的视图(高度=几个 dpi)。 查看真实代码,它是: <LinearLayout android:id="@+id/lineA" android:layout_width="fill_parent" android:layout_height="2dp" android:background="#000000" /> 请注意,它可以是任何类型的 View。 如果您不想仅使用额外的视图来显示下划线。在您的 textView 上添加此样式。 style="?android:listSeparatorTextViewStyle" 缺点是它会添加额外的属性,例如 android:textStyle="bold" android:textAllCaps="true" 您可以轻松覆盖它。 对我有用的是 <view android:layout_below="@+id/kaimla_number" android:layout_width="match_parent" android:layout_height="3dp" android:background="@color/golden"></view> <view android:id="@+id/blackLine" android:layout_width="match_parent" android:layout_height="1dp" android:background="#000000" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"/> 应用程序:layout_constraintStart_toStartOf =“父”/> 使用此视图标签,您可以水平或垂直地创建视图,只需更改高度和宽度即可使其水平和垂直。您可以简单地创建水平和垂直线。 这是水平线代码,其中视图的高度是线的厚度。 <View android:id="@+id/view" android:layout_width="match_parent" android:layout_height="1.5dp" android:layout_marginHorizontal="24dp" android:layout_marginTop="20dp" android:background="@color/green" app:layout_constraintTop_toBottomOf="@id/imgChoice" />
在compose中使用.dp扩展函数之前是否需要将Int解析为dp?
假设我在figma中有一个分辨率为1080x1920的屏幕,然后我添加20px填充,当我用compose重新创建这个布局时,我需要将20解析为dp(使用一些实用函数,例如:val Int.dp:...
Android:Recyclerview 滚动并出现折叠工具栏问题
在我的应用程序中,我使用 CollapsingtoolbarLayout 和 RecyclerView。两人都在工作。但我在滚动它们时遇到问题。我想要的是每当我直接滚动 RecyclerView 时我想要...