【发布时间】:2021-07-28 21:34:19
【问题描述】:
我正在尝试:
fragment_container.layoutParams.height = 100
fragment_container.requestLayout()
或
val params = fragment_container.layoutParams
params.height = 100
fragment_container.layoutParams = params
fragment_container.requestLayout()
两者都不起作用,这个fragment_container(它是FrameLayout)的高度仍然像在layout.xml中声明的那样
如果需要,这里是布局:
<?xml version="1.0" encoding="utf-8"?>
<pl.jawegiel.exchangerates.ClickableMotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto"
android:id="@+id/motion_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
motion:layoutDescription="@xml/main_activity_scene">
<ImageView
android:id="@+id/iv_header"
android:layout_width="match_parent"
android:layout_height="200dp"
android:src="@mipmap/exchange_rates"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent"/>
<LinearLayout
android:id="@+id/ll_toolbar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/teal_700"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="8dp"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toBottomOf="@+id/iv_header">
<RelativeLayout
android:id="@+id/rl_inside_toolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/toolbar_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/toolbar_title"
android:textSize="12sp"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="400dp"/>
<TextView
android:id="@+id/about"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:gravity="center_vertical"
android:text="@string/about"
android:layout_marginEnd="10dp"
android:textSize="18sp"
android:visibility="visible"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
</pl.jawegiel.exchangerates.ClickableMotionLayout>
你还需要知道什么?还有什么事情你需要知道?我想我已经添加了您需要的所有内容,但以防万一。提前谢谢!
【问题讨论】:
标签: android kotlin android-layout