【发布时间】:2015-12-19 16:43:40
【问题描述】:
在我的片段中,我在 LinearLayout 中有几个 TextView。我在 onViewCreated() 中动态设置文本。 高度由 android:layout_height="wrap_content" 在 XML-Layout 中设置。 但是,高度不会根据内容进行调整。它们始终保持相同的高度。
这是 XML:
<ScrollView 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"
android:background="@color/my_white_color">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/my_white_color"
android:padding="10dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/seminarImageView"
android:scaleType="fitCenter"
android:background="@color/gray3"
android:padding="1dp"
android:adjustViewBounds="true"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/titelTextView"
android:textColor="@color/blue_heading"
android:textSize="24sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/teaserTextView"
android:textColor="@color/blue1"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/bodyTextView"
android:textColor="@color/blue1"
android:textSize="15sp" />
</LinearLayout>
有什么建议吗?
【问题讨论】:
-
这似乎正是您要找的 -> Link to an older post
-
这不是我要找的:我不希望内容(文本)调整大小,我希望 TextView 调整大小,这是不同的。
-
将 android:linespacingextra="5dp" 添加到您的文本视图中
标签: android android-layout textview fragment