gpt4 book ai didi

Android - ConstraintLayout 中的 ConstraintVertical 权重不起作用?

转载 作者:行者123 更新时间:2023-11-29 16:51:35 24 4
gpt4 key购买 nike

我在 app:layout_constraintVertical_weight="5"ConstraintLayout 中使用,但它不起作用。

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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">

<TextView
android:id="@+id/txtComingSoon"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#E1E2E4"
android:text="New Courses Starting Soon.."
android:textColor="#747577"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_weight="5"
android:layout_marginTop="0dp" />

<android.support.constraint.ConstraintLayout
android:id="@+id/constImageButtons"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#FF9F00"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintVertical_weight="5"
android:layout_marginBottom="0dp">

<ImageButton
android:id="@+id/imbRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="@null"
android:scaleType="fitXY"
android:src="@drawable/ic_register"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<ImageButton
android:id="@+id/imbMedia"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="@null"
android:scaleType="fitXY"
android:src="@drawable/ic_media"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/imbRegister"
app:layout_constraintTop_toTopOf="parent" />

<ImageButton
android:id="@+id/imbWebinar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="@null"
android:scaleType="fitXY"
android:src="@drawable/ic_webinar"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/imbMedia"
app:layout_constraintTop_toTopOf="parent" />

<ImageButton
android:id="@+id/imbAboutUs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="@null"
android:scaleType="fitXY"
android:src="@drawable/ic_about_us"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/imbWebinar"
app:layout_constraintTop_toTopOf="parent" />

<ImageButton
android:id="@+id/imbNews"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="@null"
android:scaleType="fitXY"
android:src="@drawable/ic_news"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/imbAboutUs"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerMouFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/constImageButtons"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/txtComingSoon"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintVertical_weight="8" />
</android.support.constraint.ConstraintLayout>

enter image description here

我需要这个:

enter image description here

我是 ConstraintLayout 的初学者,我需要使用 ConstraintLayout,例如 LinearLayoutweight

最佳答案

try below:

 <android.support.constraint.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">

<TextView
android:id="@+id/txtComingSoon"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#E1E2E4"
android:text="New Courses Starting Soon.."
android:textColor="#747577"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@+id/recyclerMouFragment"
app:layout_constraintVertical_weight="1"/>

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerMouFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/constImageButtons"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/txtComingSoon"
app:layout_constraintVertical_weight="8" />

<android.support.constraint.ConstraintLayout
android:id="@+id/constImageButtons"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#FF9F00"
app:layout_constraintTop_toBottomOf="@+id/recyclerMouFragment"
app:layout_constraintVertical_weight="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">

<ImageButton
android:id="@+id/imbRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="@null"
android:scaleType="fitXY"
android:src="@mipmap/ic_launcher"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<ImageButton
android:id="@+id/imbMedia"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="@null"
android:scaleType="fitXY"
android:src="@mipmap/ic_launcher"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/imbRegister"
app:layout_constraintTop_toTopOf="parent" />

<ImageButton
android:id="@+id/imbWebinar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="@null"
android:scaleType="fitXY"
android:src="@mipmap/ic_launcher"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/imbMedia"
app:layout_constraintTop_toTopOf="parent" />

<ImageButton
android:id="@+id/imbAboutUs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="@null"
android:scaleType="fitXY"
android:src="@mipmap/ic_launcher"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/imbWebinar"
app:layout_constraintTop_toTopOf="parent" />

<ImageButton
android:id="@+id/imbNews"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="@null"
android:scaleType="fitXY"
android:src="@mipmap/ic_launcher"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/imbAboutUs"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>

关于Android - ConstraintLayout 中的 ConstraintVertical 权重不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46299166/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com