我希望文本视图中的文本在太长时间内换行。当我第一次打开活动时,额外的文本不可见。当我打开手机时,文字适合。当我再次将其翻转时,文本被包裹,但文本的顶部和底部被切断。我怎样才能解决这个问题?谢谢。
另外,为什么在打开活动并将其恢复为垂直状态后会出现不同的行为?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="horizontal"
android:minHeight="@dimen/list_item_height"
android:background="@color/color_accent_two">
<ImageView
android:id="@+id/image"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
/>
<LinearLayout
android:id="@+id/text_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="16dp"
android:background="@color/color_accent_two">
<TextView
android:id="@+id/tajikTextView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="bottom"
android:text="New Text"
android:textColor="@color/color_accent_one"
android:textAppearance="?android:textAppearanceMedium"
android:textStyle="bold"/>
<TextView
android:id="@+id/englishTextView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="top"
android:text="New Text"
android:textColor="@color/color_accent_three"
android:textAppearance="?android:textAppearanceMedium"
/>
<TextView
android:id="@+id/tajikLatinTextView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="top"
android:text="New Text"
android:textColor="@color/color_accent_three"
android:textAppearance="?android:textAppearanceMedium"
/>
</LinearLayout>
答案 0 :(得分:1)
试试这个: 删除权重并设置TextView height wrap_content。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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/color_accent_two"
android:minHeight="@dimen/list_item_height"
android:orientation="horizontal">
<ImageView
android:id="@+id/image"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height" />
<LinearLayout
android:id="@+id/text_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_accent_two"
android:orientation="vertical"
android:paddingLeft="16dp">
<TextView
android:id="@+id/tajikTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="New Text"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="@color/color_accent_one"
android:textStyle="bold" />
<TextView
android:id="@+id/englishTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="New Text"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="@color/color_accent_three" />
<TextView
android:id="@+id/tajikLatinTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="New Text"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="@color/color_accent_three" />
</LinearLayout>