android-relativelayout 相关问题

Android布局,显示彼此相对位置或父视图的子视图。

滚动 Android TV 时如何阻止 RecyclerView 与 TextView 重叠

我有一个 Android TV 应用程序,它在 TextView 下方有一个 RecyclerView。一切看起来都很棒,直到我单击第三个项目,导致 RecyclerView 覆盖 TextView。 我有一个 Android TV 应用程序,它在 TextView 下方有一个 RecyclerView。一切看起来都很棒,直到我单击第三个项目,导致 RecyclerView 覆盖 TextView。 <?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" android:layout_width="match_parent" android:layout_height="match_parent" android:focusable="false" android:focusableInTouchMode="false" android:keepScreenOn="true"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:clipToPadding="false" android:clipChildren="false" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent"> <TextView android:id="@+id/dateTV" android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="18sp" android:layout_marginStart="@dimen/homeHorizontalMargin" android:paddingBottom="20dp" /> <androidx.recyclerview.widget.RecyclerView android:id="@+id/recyclerView" android:layout_below="@id/dateTV" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:layout_marginHorizontal="@dimen/epgRVHorizontalMargin" android:focusable="false" android:focusableInTouchMode="false" android:descendantFocusability="afterDescendants" /> </RelativeLayout> </androidx.constraintlayout.widget.ConstraintLayout> 如何阻止 RecyclerView 与 TextView 重叠? 您的 RecyclerView 父布局具有以下属性 android:clipToPadding="false" android:clipChildren="false" 因此,当您滚动RecyclerView时,它将与布局中的其他视图重叠。 您可以将其删除。为什么在这里使用这个属性有什么具体原因要在屏幕上设计其他视图吗? 或者您有 ConstraintLayout 作为根布局,那么为什么您再次添加 RelativeLayout 并将 RecyclerView 放入此布局中。 您可以像下面这样设计您的 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" android:layout_width="match_parent" android:layout_height="match_parent" android:focusable="false" android:focusableInTouchMode="false" android:keepScreenOn="true"> <TextView android:id="@+id/dateTV" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/homeHorizontalMargin" android:paddingBottom="20dp" android:textSize="18sp" app:layout_constraintTop_toTopOf="parent" /> <androidx.recyclerview.widget.RecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="0dp" android:layout_below="@id/dateTV" android:layout_marginHorizontal="@dimen/epgRVHorizontalMargin" android:layout_marginTop="20dp" android:descendantFocusability="afterDescendants" android:focusable="false" android:focusableInTouchMode="false" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toBottomOf="@id/dateTV" /> </androidx.constraintlayout.widget.ConstraintLayout>

回答 1 投票 0

windowSoftInputMode="adjustResize" 在相对布局中绝对定位的情况下似乎不起作用

我的 Android 屏幕下部有一个 EditText,如图所示。由于一些项目限制,我应该只使用绝对定位。 当单击 EditText 时,软键...

回答 1 投票 0

安卓。如何提高回收器视图性能?

我有一个项目列表,我正在使用 RecyclerView 来显示它。 这是我的列表的一个示例: 我需要了解什么是更好地用于项目布局:RelativeLayout 或 ConstraintLayout 在我的...

回答 1 投票 0

信箱式盒子内的视频预览

我有一个纹理视图,显示来自相机的视频。纹理视图受右侧带有按钮的固定宽度框架布局的约束。它被另一个框架限制在底部......

回答 1 投票 0

如何以编程方式处理 Android 中的配置更改(屏幕方向、应用程序显示大小等)

是的,关于同一主题的堆栈溢出已经有很多答案,其中大多数都说明了以下方法: 清单.xml: 是的,关于同一主题的堆栈溢出已经有很多答案,其中大多数都说明了以下方法: Manifest.xml: <activity android:name=".MainActivity" android:configChanges="orientation|screenSize|screenLayout|keyboardHidden" </activity> 手动处理配置更改: override fun onConfigurationChanged (newConfig: Configuration) { super.onConfigurationChanged (newConfig) if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { // TODO block 1: } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { // TODO block 2: } } 现在,假设我有一个简单的 Android 应用程序,其中包含一个relativelayout,其中包含一个按钮和一个文本字段(EditView)。完整的应用程序是通过编程设计的。 在纵向模式下:文本字段和按钮是一个在另一个下面,如图所示, 在横向模式下,我希望文本字段和按钮彼此相邻,为此,我将更改上面提到的 onConfigurationChanged 方法中 TODO 块 2 内的 x、y、高度、宽度等。 同样,为了处理应用程序显示尺寸的变化(多窗口、多屏幕翻转设备),我需要做类似的事情。 (现在,我不知道如何处理这些变化)。 现在我的相对布局中只有两个视图:一个按钮和一个文本字段(EditView),假设当我的活动中有 50-60 个视图时,我需要更改每个视图的 x、y、高度和宽度视图和每个场景(屏幕方向、应用程序显示尺寸等)。 这看起来做起来和维护起来很乏味,有没有其他方法可以更省力地处理配置更改? 注意:我的整个应用程序是以编程方式设计的,没有使用jetpack compose。 PS:Android 文档也提到上述方式不是首选方式 我也浏览了此链接,但似乎对上述场景没有用。 (如果我错了请纠正我) 使用以下自由权 implementation 'com.intuit.sdp:sdp-android:1.1.0' implementation 'com.intuit.ssp:ssp-android:1.1.0'

回答 1 投票 0

Constraintlayout(在RelativeLayout中)layout_alignParentBottom从底部剪切(在应用程序的默认模式下)

我已经在RelativeLayout中添加了ConstraintLayout,并且我希望将其添加到RelativeLayout的底部。因此,当应用程序以全屏模式打开但在默认模式下ConstraintLayout会减少...

回答 1 投票 0

React 本机应用程序中未找到类相对布局错误

有没有人可以告诉我这个错误是在我将闪屏设置为我的反应本机应用程序后启动的。 在添加启动画面之前,我的应用程序正在运行,我认为

回答 1 投票 0

来自 TextInput 和 launch_screen 文件的相对布局错误

调试器给我的错误消息: 这将是向我抛出错误的组件。具体来说就是 TextInput。我尝试将其从组件中删除,但出现错误

回答 2 投票 0

如果没有记录,ImageView 不会显示图像

我面临的问题真的很奇怪。如果没有可用记录,我正在尝试显示图像。但图像不可见。 这是流程。 我有 content_main.xml,其中有一个回收 vi...

回答 1 投票 0

Android:相对布局内的两个以编程方式创建的子元素未正确对齐在水平线上

我想在相对布局中并排创建两个元素。这是我的代码: int pixels = (int) (20 * scale + 0.5f); ImageView img = new ImageView(candidate_registration_1.this); 文本视图...

回答 1 投票 0

如何找到这个布局文件 app/src/main/res/layout/activity_main.xml

我学习了一门课程,它告诉我编辑这个布局文件,我怎么能找到它,因为我搜索了它但我没有找到它 课程导师告诉我: “” 在新版本的 Android ...

回答 3 投票 0

如何修复我在 Android Studio 上的菜单,它在我的活动中不可见

我在 Res、Directory Res 上创建了菜单,然后在菜单中创建了 dashboard_menu。当我运行菜单时,它不可见。这是Java上的代码。 我试图将我的 mini sdk 从 23 更改为 2 ...

回答 1 投票 0

如何使线性布局和相对布局按百分比共享水平屏幕空间?

如何让线性布局和相对布局按百分比共享水平空间? 左边的LinearLayout需要有屏幕的百分比宽度,右边的RelativeLayout...

回答 1 投票 0

relativeLayout.setBackground(ContextCompat.getDrawable(context, R.drawable.sample_drawable));正在API 19上崩溃的应用。

我有一个简单的布局文件,我想在主容器的背景中使用一个可绘制的文件。

回答 1 投票 1

setLayoutParams()在API中不起作用 <= 23

我试图将一个句子分割成单词,并将单词以TextViews的形式放入RelativeLayout中,但是当我将layoutparams设置为TextView时,在API 23和更老版本中并没有生效。在API 23及以上的版本中,它可以正常工作,从 ...

回答 1 投票 0

约束布局有底部和顶部空间

我正在用Constraint布局构建一个应用程序,但它的底部和顶部有额外的空间。我找不到它们是从哪里来的。我检查了大概十次,从上到下的所有代码,但没有边距或 ...

回答 1 投票 1

增加ImageView的可点击区域

我已经创建了如下所示的RelativeLayout作为工具栏的一部分。布局由两个图像和图像下方的细线组成。对于两个图像,我增加了宽度,因为然后...

回答 2 投票 0

RelativeLayout在ConstraintLayout中的位置不好

我认为我所做的一切都是正确的,但是ConstraintLayout中的RelativeLayout并没有执行我的命令。当我在RelativeLayout下添加一些内容时,它应该会更小,并为其他项目腾出空间...

回答 1 投票 0

运行应用程序时键盘布局边缘出现了?

这是我使用dp尺寸使用键盘的相对布局创建的布局,但是当我尝试在手机上使用键盘时,不知何故,如下图所示,键盘的右边缘被裁剪了,什么...

回答 1 投票 0

在列表视图项中显示布局可见性

这是我的listview项目xml代码。我有2个相对布局作为项目。我需要实现的是,以动画化底部相对布局的可见性,如单击顶部相对布局时的下拉菜单。

回答 1 投票 0

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