布局定义用户界面的可视结构,例如活动,片段或应用程序窗口小部件的UI。
我的关闭按钮有一个标准矢量资源。关闭按钮在整个应用程序中以白色使用,因此我不能只更改填充颜色。我需要黑色的,但我被告知要重复使用 w...
Kotlin Android 应用程序的回收器视图中的图像下方未显示文本
我在 Android Studio 中创建了一个用 Kotlin 编写的 Android 应用程序。其中一页显示了自行车的概述,其名称如下。在 Android Studio 中工作就像一个魅力,我测试过的所有模拟器......
我已经尝试到处搜索,但我似乎无法弄清楚这一点。基本上,我有一个带有 Scrollview 和其中元素的布局。我想在滚动视图中放置一个按钮,这将...
如何在 Android Studio 中使用 xml 布局填充列表视图项?
我正在开发一个 Android 项目,我想用 XML 布局填充列表视图项。该布局由图像文本框和 TextView 组成。 我该怎么做?
如何让recyclerviews在android中从右到左和从左到右水平滚动?
我在一个片段中有 3 个回收器视图,我希望每个回收器视图都在另一个之下,然后当我滚动时,它们应该从左到左滚动。他们都不应该
如何在android中创建像材质3这样的自定义文本输入布局,因为对我来说现有的材质3和材质2不满足要求
设计师要求我自定义编辑文本或输入文本布局,因此我尝试查看 MD2 和 MD3 文档,但没有找到任何有用的东西。 这是要求,...
如何在 Android Studio 中删除 ImageView 和屏幕/父级边缘之间的额外空间?
所以我本质上是在尝试删除图像视图上方的一些额外空间,我将其用作应用程序页面顶部的横幅(如下图所示)。 图片 - 额外空间
如何在recyclerview的cardview中对齐textview
我正在使用数据库中的数据创建一个RecyclerView。为了制作一行,我创建了一个资源文件 row_layout.xml,它有两个 TextView。我希望它在 CardView 中,但在创建
我无法在桌面中央获取图像。图像始终位于左侧。它是LinearLayout 我的一些ScrollView。 我无法在桌面中央获取图像。图像始终位于左侧。它是LinearLayout 我的一些ScrollView。 <android.support.v7.widget.CardView android:layout_width="wrap_content" android:layout_height="wrap_content" app:cardCornerRadius="80dp" app:cardElevation="10dp" android:gravity="center" android:orientation="vertical"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/titelbild280x280" android:layout_centerHorizontal="true" android:layout_centerVertical="true"/> </android.support.v7.widget.CardView> CardView 是 FrameLayout 的扩展。因此,您应该使用与 FrameLayout 中相同的布局值。 要将子视图居中,请使用: android:layout_gravity="center" 所以你的布局变成: <android.support.v7.widget.CardView android:layout_width="wrap_content" android:layout_height="wrap_content" app:cardCornerRadius="80dp" app:cardElevation="10dp" android:orientation="vertical"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:src="@drawable/titelbild280x280" /> </android.support.v7.widget.CardView> 但是请注意,此示例中的 CardView 使用了wrapp_content,因此它将牢牢地包裹图像,并且不会留下任何内容居中。为了使重力起作用,CardView 必须大于 ImageView。 您必须使用布局(ConstraintLayout或RelativeLayout或LinearLayout)来管理卡片视图中的多个视图 目前android UI系统与ConstraintLayout深度耦合,可以轻松处理复杂的布局,因此以下代码可能对您有帮助 <android.support.v7.widget.CardView android:layout_width="wrap_content" android:layout_height="wrap_content" app:cardCornerRadius="80dp" app:cardElevation="10dp" android:gravity="center" android:orientation="vertical"> <android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/titelbild280x280" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent"/> </android.support.constraint.ConstraintLayout> </android.support.v7.widget.CardView> 谢谢。 试试这个希望它对你有用 <android.support.v7.widget.CardView android:layout_width="wrap_content" android:layout_height="wrap_content" app:cardCornerRadius="80dp" app:cardElevation="10dp" android:gravity="center" android:foreground="?android:attr/selectableItemBackground" android:clickable="true" android:orientation="vertical"> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <ImageView android:id="@+id/featureimage" android:layout_width="100dp" android:layout_height="100dp" android:layout_centerInParent="true" android:src="@drawable/image"/> </RelativeLayout> </android.support.v7.widget.CardView> 只需尝试一下: <?xml version="1.0" encoding="utf-8"?> <androidx.cardview.widget.CardView 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="wrap_content" tools:context=".MainActivity"> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:src="@drawable/some_img" /> </androidx.cardview.widget.CardView> 请尝试以下代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" tools:context=".MainActivity" android:gravity="center"> <android.support.v7.widget.CardView android:layout_width="wrap_content" android:layout_height="wrap_content" app:cardCornerRadius="10dp" app:cardElevation="10dp" android:orientation="vertical"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/titelbild280x280" android:layout_gravity="center"/> </android.support.v7.widget.CardView> </LinearLayout> 我希望它对你有用。 对我来说最简单的方法是在我的cardView中使用相对布局,然后使用android:layout_centerInParent =“true”。 当相对布局的宽度和高度与父级匹配(父级是cardView)时,这非常有效。
我正在尝试将button_pair定位到屏幕底部。我尝试将所有内容包装在 LinearLayout 中并实现与下面相同的 Space 组件,但它仍然无法定位...
Android 开发中将视图缩放到父级尺寸一定百分比的最佳方法是什么?
在我当前的项目中,有很多实例我想将视图缩放为其父容器的 1/8,因为我必须利用我可以使用的所有空间,因为我有很多功能...
如何使用 Jetpack Compose 垂直旋转堆叠文本?
尝试对齐文本元素,如下图所示: 如何在 Jetpack Compose 中做到这一点? 通常我会使用垂直方向的线性布局和旋转 90 度的 TextView。哇...
我怎样才能避免java.io.StreamCorruptedException:无效的流头:00000000
当我添加如下所示的文本输入 xml 标签时 当我添加如下所示的文本输入 xml 标签时 <EditText android:id="@+id/editText2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="60dp" android:layout_marginEnd="60dp" android:ems="10" android:gravity="start|top" android:inputType="textAutoCorrect" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/imageButton" app:layout_constraintStart_toEndOf="@id/imageView3" app:layout_constraintTop_toTopOf="parent" /> 我收到错误了 Execution failed for task ':app:kaptDebugKotlin'. > java.io.StreamCorruptedException: invalid stream header: 00000000 清理项目并再次尝试运行。 我想这会解决这个问题。
自定义 textCursorDrawable 未反映在 Android 10 及更高版本的设备中
XML 代码 XML 代码 android:id="@+id/email_et_ll" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" app:boxStrokeColor="@color/input_text_custom_outline_color" app:boxStrokeErrorColor="@android:color/holo_red_light" app:hintTextColor="@color/yellow" android:layout_marginStart="16sp" android:layout_marginTop="16sp" android:layout_marginEnd="16sp" android:hint="@string/hello_gmail_com" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/login_info_txt" app:shapeAppearance="@style/input_text_rounded_corner" app:startIconDrawable="@drawable/baseline_email_24"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/email_et" android:layout_width="match_parent" android:layout_height="wrap_content" android:cursorVisible="true" android:textCursorDrawable="@drawable/cursor_bg" /> </com.google.android.material.textfield.TextInputLayout> 这是我的XML代码,我在其中使用自定义textCursorDrawable制作了一个输入文本字段,但此更改仅反映在android 8,9中,而不反映在更高版本中,如何解决这个问题?我需要帮助。 以下是截图。 Android-8 Android-9 Android-10 对于更高版本 11,12 也是如此(已测试)。 在 TextInputLayout 中使用自定义主题 android:theme="@style/TextInputEditText" <com.google.android.material.textfield.TextInputLayout android:id="@+id/loginEmailTextInput" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/_20sdp" android:layout_marginTop="@dimen/_10sdp" android:layout_marginEnd="@dimen/_20sdp" app:boxStrokeWidth="0dp" app:boxStrokeWidthFocused="0dp" app:hintEnabled="false" android:theme="@style/TextInputEditText" app:layout_constraintTop_toBottomOf="@+id/textView6" app:shapeAppearanceOverlay="@style/ShapeAppearance.Material3.Corner.Medium" app:startIconDrawable="@drawable/emailicon" app:startIconTint="@color/greycolor"/> 样式.xml <style name="TextInputEditText" parent=""> <item name="colorControlActivated">@color/black</item> </style>
正如我在问题中所写,我想更改 XML 中 Spinner 的下拉箭头(默认箭头,不是自定义箭头或类似的东西)的颜色,但问题是我不能...
即使顶视图的高度比屏幕大/小,如何设置底视图始终低于顶视图?
[我在这样的相对布局中有 3 个布局]1 我的目标是使布局 3 始终位于布局 2(回收器视图)下方。 当列表项尺寸较小时,它可以完美工作,但是当...
在您发布 stackoverflow 答案的链接之前,请注意我可能已经尝试过。 我使用 android studio 和 kotlin。 custom_lvlmeter_channel.xml 只是
有没有办法仅使用约束布局将图像的一半放置在另一个图像的顶部。我知道可以使用相对布局和框架布局来完成,但在约束布局的情况下是存在的
如何在android studio Kotlin中创建像uc浏览器搜索栏工具栏一样的搜索栏?
首页是uc浏览器工具栏 当用户单击主屏幕上的搜索栏时,它会展开左端用户所需的搜索引擎和右端取消按钮以及在搜索之间的麦克风...
在我的绘图应用程序中,我正在使用以下代码在画布上进行绘画: currentPaint = new Paint(); currentPaint.setDither(true); currentPaint.setColor(0x00000000); ...