【发布时间】:2016-06-15 06:25:55
【问题描述】:
[问题已解决] 我不知道为什么 height: wrap_content 没有按预期工作,我只是将其更改为匹配父项。总之,问题解决了。不想再在这件奇怪的事情上花更多的时间了。
我正在使用 LinearLayout 来构造 CardView。但是,我遇到了这种奇怪的情况。 Jinesh Francis 的代码运行良好,但是当我将配置复制并粘贴到我的代码中时,问题仍然存在。
为什么长标题不能完全显示?
布局如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/movieCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_gravity="center"
android:background="@color/bacgroundCardView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/movieImage"
android:layout_width="70dp"
android:layout_height="90dp"
android:layout_marginBottom="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="4dp"
android:scaleType="fitXY"
android:src="@drawable/selfie" />
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp">
<TextView
android:id="@+id/movieTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="8"
android:textSize="15dp"
android:textColor="#000"
android:textStyle="bold"
android:text="Long long long long long long long long Title"/>
<TextView
android:id="@+id/movieRating"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:textSize="12dp"
android:textStyle="bold"
android:text="7.0" />
<CheckBox
android:id="@+id/checkBox"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:scaleX="0.70"
android:scaleY="0.70" />
</LinearLayout>
<TextView
android:id="@+id/movieDescription"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textSize="10dp"
android:text="So many many many many many many many many many many many many description" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
感谢您的建议
【问题讨论】:
-
只写XML标签是不够的。编辑您的帖子并包含属性。
-
发布您的完整布局文件
-
你在 relativeLayout 中使用 LinearLayout,并设置标题的权重.. 这就是它给出这个输出的原因
-
我已经切换到LinearLayout,但问题依旧...
-
我不知道为什么 height: wrap_content 不能按预期工作,我只是将其更改为匹配父项。总之,问题解决了。不想再花更多时间在这件奇怪的事情上。
标签: android xml android-linearlayout