【发布时间】:2019-11-02 02:14:20
【问题描述】:
我正在开发一个应用程序的设置页面,用户需要根据自己的喜好设置文本大小。我正在预览cardView 中的一段示例文本,以便他们可以查看并应用他们的更改。
我的问题是,随着文本的增加或减少,卡片视图会自行调整。如何防止 cardView 在文本更改时推送其他视图?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:background="@android:color/white"
android:layout_height="match_parent"
<androidx.cardview.widget.CardView
android:id="@+id/previewView"
android:layout_margin="10dp"
android:layout_width="match_parent"
card_view:cardElevation="3dp"
card_view:cardUseCompatPadding="true"
android:layout_height="wrap_content">
<TextView
android:id="@+id/previewText"
android:text="My Text"
android:fontFamily="@font/muli_bold"
android:layout_gravity="center"
android:textSize="29sp"
android:gravity="center"
android:textColor="@color/customTextColor"
android:padding="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</androidx.cardview.widget.CardView>
<ScrollView
android:layout_below="@+id/previewView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
//other views here
</RelativeLayout>
</ScrollView>
</RelativeLayout>
【问题讨论】:
-
给定高度值?
-
是的。这样其他视图不受影响