简体   繁体   English

cardview中的所有文本未显示在scrollview中

[英]All the text from cardview is not showing in scrollview

i am trying to make CardView with text inside it but the problem is i am not able to scroll through entire text section, some part of text is missing at the end. 我正在尝试使用其中的文本制作CardView ,但是问题是我无法滚动浏览整个文本部分,最后缺少一部分文本。
How to solve this? 如何解决呢?

Here is my code 这是我的代码

<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"

android:fillViewport="true">

<RelativeLayout
android:orientation="vertical"
android:gravity="start"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<android.support.v7.widget.CardView
android:id="@+id/card_view_princitext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
card_view:cardCornerRadius="5dp"
card_view:contentPadding="10dp"
>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TextView
        android:id="@+id/textView"
        android:textSize="15sp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/pmsg"
        android:textColor="#000000" />
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
</ScrollView>

Change this line 更改此行

android:layout_height="0dp" 

to

android:layout_height="match_parent"

Root layout cannot have layout_weight property, it will not make any effect 根布局不能具有layout_weight属性,它不会起作用

There might be problem with your support library which you are using for cardview. 您用于Cardview的支持库可能存在问题。 The compiled sdk version and support lib version should be same. 编译后的sdk版本和支持的lib版本应该相同。

for example: In build.gradle 例如:在build.gradle中

if compileSdkVersion 23 then 如果compileSdkVersion 23然后

in dependencies you should use 在依赖中,您应该使用

compile 'com.android.support:cardview-v7:23.0.0' 编译'com.android.support:cardview-v7:23.0.0'

Check both the versions in build.gradle. 检查build.gradle中的两个版本。

ps: if you use support lib version 24 studio suggest you the following ps:如果使用支持库版本24 Studio,建议您执行以下操作

"this support library should not use a different version (24) than the compilesdkversion (23)" “此支持库不应使用与compilesdkversion(23)不同的版本(24)”

best luck ! 好运 !

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM