Android layout 如何在同一版面上包含一个图像(占高度的50%)和多个文本视图?

Android layout 如何在同一版面上包含一个图像(占高度的50%)和多个文本视图?,android-layout,Android Layout,几天来,我一直在处理一个我自己无法解决的问题 我正在构建一个Android应用程序,在上面可以显示新闻列表,一页一条新闻,或者在Android手机上查看。我只需要向下滚动查看第二条、第三条等新闻。基本上,我希望有一个图像,将采取屏幕的前半部分和屏幕的另一半将显示文本视图 我已经找到了一些有趣的答案,比如坚果,没有一个能解决我的问题 正如您将看到的,我有两个布局是线性布局的一部分 我无法在一个视图中仅获取一个新闻1图像和4个文本视图的内容,这将占用100%的版面高度。我在为每一条新闻寻找相同的结果

几天来,我一直在处理一个我自己无法解决的问题

我正在构建一个Android应用程序,在上面可以显示新闻列表,一页一条新闻,或者在Android手机上查看。我只需要向下滚动查看第二条、第三条等新闻。基本上,我希望有一个图像,将采取屏幕的前半部分和屏幕的另一半将显示文本视图

我已经找到了一些有趣的答案,比如坚果,没有一个能解决我的问题

正如您将看到的,我有两个布局是线性布局的一部分

我无法在一个视图中仅获取一个新闻1图像和4个文本视图的内容,这将占用100%的版面高度。我在为每一条新闻寻找相同的结果

它应该类似于Flipboard应用程序,以防您听说过此应用程序

这是我的xml文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:transitionGroup="false"
    android:weightSum="2">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/news_hockey2"
            android:adjustViewBounds="true"
            />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="47dp"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="title"
                android:id="@+id/title"
                android:textIsSelectable="true"
                android:layout_weight="0.1" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:id="@+id/date_of_pub_list"
                android:text="date_of_pub"
                android:layout_weight="0.1" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="121dp"
                android:text="article"
                android:id="@+id/article"
                android:layout_marginBottom="10dp"
                android:layout_weight="0.2"
                android:phoneNumber="false" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="35dp"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:text="link"
                android:id="@+id/link"
                android:layout_marginBottom="15dp"
                android:layout_weight="0.1" />

        </LinearLayout>
    </RelativeLayout>

</LinearLayout>

您没有理由在RelativeLayouts中将ImageView或LinearLayout与TextView包装在一起。删除这些选项并将Linearlayout和ImageView设置为:

android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"