TextView 在 LinearLayout 中被切断

Sre*_*ree 3 java android textview android-layout android-linearlayout

我正在尝试添加两个不同高度的不同文本视图,如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/single_margin"
android:layout_marginLeft="@dimen/double_margin"
android:layout_marginRight="@dimen/double_margin"
android:layout_marginTop="@dimen/single_margin"
android:baselineAligned="false"
android:gravity="center"
android:orientation="horizontal">


<TextView
    android:id="@+id/newsfeed_ad_title"
    android:layout_width="0px"
    android:layout_height="match_parent"
    android:layout_marginRight="28dp"
    android:layout_weight="3"
    android:fontFamily="sans-serif-light"
    android:gravity="center_vertical"
    android:singleLine="false"
    android:text="This is example text view that will mess up the height!"
    android:textColor="@color/dark_blue"
    android:textSize="@dimen/ad_title_text" />


<TextView
    android:id="@+id/newsfeed_ad_info_button"
    android:layout_width="0px"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_weight="2"
    android:background="@drawable/selector_rounded_box_light_blue"
    android:fontFamily="sans-serif-light"
    android:gravity="center"
    android:paddingBottom="@dimen/single_margin"
    android:paddingLeft="@dimen/double_margin"
    android:paddingRight="@dimen/double_margin"
    android:paddingTop="@dimen/single_margin"
    android:text="Learn More"
    android:textColor="@color/dark_blue"
    android:textSize="@dimen/body_text" /> </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

结果是这样的:

在此处输入图片说明

(不要介意上面的阴影。我裁剪了图像,阴影来自操作栏)

线性布局的高度由较小的文本视图而不是较大的文本视图决定。为什么?我该如何修复它?提前致谢

Nav*_*Rao 5

使 textview 的高度wrap_content将解决问题

android:id="@+id/newsfeed_ad_title"
    android:layout_width="0px"
    android:layout_height="wrap_content"
Run Code Online (Sandbox Code Playgroud)