android-layout 相关问题

布局定义用户界面的可视结构,例如活动,片段或应用程序窗口小部件的UI。

从下到上逐渐填充一个圆圈android

我使用 xml 创建了一个带有笔划和白色背景的圆圈。如何根据用户操作(例如连续按下按钮)从下到上逐渐填充? 有免费的图书馆吗

回答 1 投票 0

将带有 xml 的实时 Android Kotlin 项目隐藏到 Compose UI 项目中是个好习惯吗

我有一个用 kotlin 编写的实时项目,采用 xml 和 MVP 架构。 我想将其更新为具有干净架构的 Compose UI。 我知道同时具有 xml 和 compose ui 的应用程序可能...

回答 1 投票 0

LayoutParams 权重出乎意料地起作用

我正在尝试创建带有 2 个子 LinearLayout 的 LinearLayout。我无法使用 XML,应该以编程方式进行此操作。 对于家长我申请: 布局参数(MATCH_PARENT,WRAP_CONTENT,1f) 第一个孩子:

回答 1 投票 0

如何让布局在前面?安卓工作室

<LinearLayout android:id="@+id/toplayout" android:layout_width="0dp" android:layout_height="wrap_content" android:orientation="horizontal" app:layout_constraintBottom_toTopOf="@id/filterlayout" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> <LinearLayout android:id="@+id/menulayout" android:layout_width="65dp" android:layout_height="50dp" android:layout_marginLeft="16dp" android:layout_marginTop="15dp" android:background="@drawable/formenulayout" android:elevation="10dp" android:orientation="vertical" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.0" > <ImageButton android:id="@+id/menu" android:layout_width="wrap_content" android:layout_height="50dp" android:layout_gravity="center" android:backgroundTint="@color/white" app:srcCompat="@drawable/menu_button" /> <ImageButton android:id="@+id/settings" android:layout_width="35dp" android:layout_height="35dp" android:layout_gravity="center" android:layout_marginTop="2dp" android:background="@drawable/gear" android:visibility="gone" app:useMaterialThemeColors="false" /> </LinearLayout> <com.google.android.material.card.MaterialCardView android:id="@+id/materialCardView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" app:cardCornerRadius="12dp" app:cardElevation="8dp" app:cardUseCompatPadding="true" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/menulayout" app:layout_constraintTop_toTopOf="parent"> <androidx.appcompat.widget.SearchView android:id="@+id/searchView" android:layout_width="match_parent" android:layout_height="wrap_content" app:iconifiedByDefault="false" app:layout_constraintStart_toStartOf="@id/menulayout" app:queryBackground="@android:color/transparent" app:queryHint="Search here" /> </com.google.android.material.card.MaterialCardView> </LinearLayout> 您好,这是我的主要活动代码。当我按下菜单 imageButton 时,菜单布局的高度会增加,并且它工作正常,但问题是,因为菜单布局的高度增加,它会导致 toplayout 的高度增加,而我不希望它这样做。 我怎样才能做到,当菜单布局的高度增加时,它将位于所有内容的前面,并且顶部布局保持不变。 尝试使用 match_parent 而不是换行内容

回答 1 投票 0

从 Kotlin 中的文本更改事件添加 ListViewItem

如果用户在 ListViewItem 文本中键入:“添加新项目”我想添加一个新项目。 到目前为止,这是我的代码: 类 DataModel 内部构造函数( var 检查:布尔值, var item描述:...

回答 1 投票 0

Android - 无法按预期设置按钮边框

我前几天刚开始学习Android。今天当我玩 Button 时,我注意到我无法按预期设置边框。 下面的 xml 文件: Activity_main.xml 中的按钮部分:...

回答 4 投票 0

向 Android 导航抽屉添加图标?

我正在创建一个实现 Android 新导航抽屉布局的应用程序。可以在此处和此处找到此布局的文档。 在设计文档以及 n...

回答 4 投票 0

为什么我的卡片视图在 Android Studio 中超出了整个宽度?

我正在使用此卡片视图(蓝色)和回收器视图中的另一个卡片视图来显示发送和接收的消息。 但是卡片视图(蓝色)覆盖了整个宽度,正如您在图片中看到的那样,我无法...

回答 1 投票 0

默认显示的 Getter:显示!'已弃用。在 Java 中已弃用

我需要屏幕的宽度。但最近发现 Android defaultDisplay 已弃用,并显示消息: defaultDisplay 的 Getter:显示!'已弃用。在 Java 中已弃用 代码: val 显示指标 =

回答 11 投票 0

为什么我的布局在物理设备上会崩溃?

我正在学习 android studio,参加 Udemy 课程。 课程本身一切都很好,我也相处得很好。唯一的问题是,我的笔记本电脑很弱,比如 8GB 的内存很弱。所以运行模拟器

回答 2 投票 0

有没有办法删除android中按钮的默认样式?

我在 android studio xml 文件中有按钮,当我更改它时它不会改变形状和颜色 我不想创造自己的风格 看起来怎么样 这是我的代码: 我在 android studio xml 文件中有按钮,当我更改它时,它的形状和颜色没有改变 我不想创造自己的风格 看起来怎么样 这是我的代码: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".fragments.PlantsListFragment"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="10dp" android:background="#1F1F27"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/spaces" android:textColor="@color/white" android:textSize="20sp" android:layout_centerInParent="true" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/rounded_square" android:backgroundTint="#1C2F33" /> </RelativeLayout> </FrameLayout> 如果需要的话,这里还有我的 rounded_square.xml 文件: <?xml version="1.0" encoding="utf-8"?> <shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#1C2F33" /> <corners android:radius="30dp" /> </shape> 我希望这个按钮的颜色为“#1C2F33”并且我希望它有圆角 不要使用Button,而是使用AppCompatButton,然后对其应用可绘制的背景形状。您也不需要背景色调,因为颜色已经在可绘制形状中指定。 <androidx.appcompat.widget.AppCompatButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/rounded_square" /> 还有更多背景信息。 您不是删除样式,而是替换它。 默认情况下,Android 中的每个控件都继承自其应用程序(您在清单中指定的 launchTheme)或活动的主题(也在清单中指定)传递的主题。 控件可以有自己的样式,您只需创建一个样式然后将其应用到您的控件即可。该主题将自动替换从其父上下文(活动/应用程序)传递下来的主题。 如果您使用 Material 主题,请记住仅使用 AppCompat 控件。 AppCompat 允许更轻松的自定义,而不是基本控件(例如按钮)。

回答 1 投票 0

在 React Native 中嵌入原生 Android Activity

我正在使用这个库在 android 中以 React Native 方式制作标签栏 https://github.com/aksonov/react-native-tabs 我必须在其中一个页面中打开本机 Android 活动。 可以请告诉我吗...

回答 1 投票 0

如何让Android应用程序认为设备处于水平模式

所以基本上我想在android电视上运行一些本机android应用程序,一些应用程序只是不能在水平模式下工作,除非应用程序有视频并且是全屏的,所以应用程序是否有可能认为...

回答 2 投票 0

Android:手机和平板电脑之间很难实现相同的布局比例/长宽比

当我说“相同的布局比例”时,我主要指的是文本大小,但也指一般的视图。 我一直读到 sp 文本大小单位与屏幕无关,但这不是

回答 1 投票 0

TextInput 在小屏幕手机上显示太窄

在以下 xml 中,“message_entry”在小屏幕 (240 x 320) 上显示太窄,但在较大屏幕 (480 x 640) 上显示良好。 在以下 xml 中,“message_entry”在小屏幕 (240 x 320) 上显示太窄,但在较大屏幕 (480 x 640) 上显示良好。 <androidx.cardview.widget.CardView android:id="@+id/reply_bar_card" android:layout_width="match_parent" android:layout_height="wrap_content" app:cardBackgroundColor="@color/replyBarCard" app:cardCornerRadius="24dp" app:cardElevation="5dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:paddingBottom="24dp"> <ProgressBar android:id="@+id/send_progress" style="@style/Widget.AppCompat.ProgressBar.Horizontal" android:layout_width="match_parent" android:layout_height="3dp" android:indeterminate="true" android:visibility="invisible" /> <HorizontalScrollView android:id="@+id/attached_image_scroller" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/message_list_padding" android:layout_marginEnd="@dimen/message_list_padding" android:paddingTop="8dp" android:paddingBottom="8dp" android:scrollbars="none" android:visibility="gone"> <LinearLayout android:id="@+id/attached_image_holder" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="12dp" android:layout_marginEnd="12dp" android:orientation="horizontal" /> </HorizontalScrollView> <LinearLayout android:id="@+id/smart_reply_container" android:layout_width="match_parent" android:layout_height="56dp" android:layout_marginStart="@dimen/message_list_padding" android:layout_marginEnd="@dimen/message_list_padding" android:gravity="end" android:orientation="horizontal" android:visibility="gone"> <ImageButton android:id="@+id/close_smart_replies" android:layout_width="32dp" android:layout_height="48dp" android:layout_gravity="center_vertical" android:layout_marginStart="8dp" android:background="?selectableItemBackgroundBorderless" android:clickable="true" android:contentDescription="@string/use_smart_replies" android:src="@drawable/ic_cancel" android:tint="@color/secondaryText" /> <LinearLayout android:id="@+id/smart_reply_suggestions_container" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginEnd="12dp" android:layout_weight="1" android:gravity="end" android:orientation="horizontal" /> </LinearLayout> <LinearLayout android:id="@+id/send_bar" android:layout_width="match_parent" android:layout_height="50dp" android:layout_marginStart="@dimen/message_list_padding" android:layout_marginEnd="@dimen/message_list_padding" android:alpha="0" android:clipToPadding="false" android:gravity="center_vertical|start" android:orientation="horizontal" android:padding="8dp" android:translationY="-32dp"> <ImageButton android:id="@+id/select_sim" android:layout_width="32dp" android:layout_height="48dp" android:background="?selectableItemBackgroundBorderless" android:clickable="true" android:contentDescription="@string/select_sim" android:src="@drawable/ic_sim" android:tint="@color/secondaryText" android:visibility="gone" /> <ImageButton android:id="@+id/view_scheduled_messages" android:layout_width="32dp" android:layout_height="match_parent" android:background="?selectableItemBackgroundBorderless" android:clickable="true" android:contentDescription="@string/view_scheduled_messages" android:src="@drawable/ic_schedule_small" android:tint="@color/secondaryText" android:visibility="gone" /> <FrameLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginEnd="8dp"> <ImageButton android:id="@+id/attach" android:layout_width="32dp" android:layout_height="48dp" android:layout_gravity="center_vertical|start" android:background="?selectableItemBackgroundBorderless" android:clickable="true" android:contentDescription="@string/attach" android:src="@drawable/ic_attach" android:tint="@color/secondaryText" /> <TextView android:id="@+id/text_counter" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom|center_horizontal" android:layout_marginBottom="2dp" android:gravity="center_horizontal" android:textColor="@color/secondaryText" android:textSize="12sp" /> </FrameLayout> <com.google.android.material.textfield.TextInputEditText android:id="@+id/message_entry" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="@null" android:backgroundTint="@color/drawerBackground" android:hint="@string/type_message_to" android:imeOptions="actionSend|flagNoExtractUi" android:inputType="textCapSentences|textAutoCorrect|textMultiLine" android:maxLines="@integer/message_list_fragment_line_entry_count" android:minHeight="40dp" android:padding="8dp" android:paddingStart="8dp" android:paddingEnd="18dp" android:scrollHorizontally="false" android:textSize="16sp" /> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/send" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:contentDescription="@string/send_message" android:src="@drawable/ic_send" app:elevation="0dp" app:fabSize="mini" app:rippleColor="@android:color/white" /> </LinearLayout> <ViewStub android:id="@+id/attach_stub" android:layout_width="match_parent" android:layout_height="@dimen/attach_menu_height" android:layout="@layout/view_attach_menu" /> </LinearLayout> </androidx.cardview.widget.CardView> 小屏幕:(添加红框用于说明) 大屏幕:(添加红框作为说明) 预期的行为就像大屏幕,其中“message_entry”尽可能宽。为什么“message_entry”在小屏幕上那么窄?我该如何解决它? 原来是因为dimens.xml文件夹下有多个res文件造成的。这用于支持多种屏幕尺寸,在较小屏幕的 dimens.xml 中,有 <dimen name="message_list_padding">96dp</dimen>。一旦更改为0dp,布局就如预期的那样。 有关多个 dimens.xml 文件的更多信息,请参阅此答案中的#2。

回答 1 投票 0

如何将图像放在按钮上android studio

我有一个512x512px的齿轮png图像(用于设置),我希望它放在一个按钮上。 我试图在可绘制的目录中创建一个目录以保持事物井井有条,但这不起作用,所以我把...

回答 1 投票 0

在Android中的列表视图和网格视图之间高效切换,平滑过渡

我正在尝试实现一个视图切换,使用户能够在Android中的“列表视图”和“网格视图”之间切换。然而,我已经做到了这一点,但我对结果并不满意

回答 1 投票 0

为什么 Android Studio 在我的项目中使用自定义样式时出现问题?

在布局中引用我的项目自定义样式之一时,我都会收到有关无关输入的语法错误。语法错误 样式仍然正确应用于布局和项目

回答 1 投票 0

如何以编程方式在聊天窗口中显示位置消息,就像android中的whatsapp一样?

我正在开发一个聊天应用程序。用户可以像 Whatsapp 一样发送位置信息。 (我不是在谈论共享实时位置功能)。对于这个要求,我使用了谷歌地点选择器......

回答 4 投票 0

如何解决android Edittext光标位置问题与对齐跨度

我正在开发简单的android编辑器应用程序。因为我使用了对齐跨度。如果我将对齐方式正常(左)更改为相反(右)或居中,则光标无法正确渲染。 设备:N...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.