0

Ich habe diese Layout-Datei für ein Fragment, das nicht das letzte Textansicht Element, tv_notice_date anzeigt, wenn der Inhalt die Bildschirmhöhe überschreitet. Ich habe der Kartenansicht eine Bildlaufleiste hinzugefügt, aber die Bildlaufleiste wird nicht angezeigt.Cardview versteckt einige Elemente, Bildlaufleisten funktionieren nicht

fragment_notice.xml

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

    <android.support.v7.widget.CardView 
     android:id="@+id/card_view" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:scrollbars="vertical" 
     android:layout_margin="4dp" 
     card_view:cardCornerRadius="4dp" 
     card_view:cardElevation="1dp"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 
      <!--Title of notice--> 
      <TextView 
       android:id="@+id/tv_notice_title" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" 
       android:text="Title of Notice" 
       android:layout_gravity="center" 
       android:textAppearance="?android:textAppearanceLarge" 
       android:textSize="20sp" 
       android:textStyle="bold"/> 

      <TextView 
       android:id="@+id/tv_notice_summary" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:padding="10dp" 
       android:text="@string/notice_body" 
       android:textAppearance="?android:textAppearanceMedium" 
       android:textSize="15sp"/> 
     <!--Date of Notice--> 
     <TextView 
      android:id="@+id/tv_notice_date" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="5dp" 
      android:text="Mon, Nov 28, 2016. 8:56 AM" 
      android:textColor="#0D47A1"/> 
    </LinearLayout> 
</android.support.v7.widget.CardView> 
</LinearLayout> 

strings.xml

<string name="notice_body"> 
    Summary of the very first post...Summary of the very first post...Summary of the very first post... 
    Summary of the very first post...Summary of the very first post...Summary of the very first post... 
    Summary of the very first post...Summary of the very first post...Summary of the very first post... 
    Summary of the very first post...Summary of the very first post...Summary of the very first post... 
    Summary of the very first post...Summary of the very first post...Summary of the very first post... 
    Summary of the very first post...Summary of the very first post...Summary of the very first post... 
    Summary of the very first post...Summary of the very first post...Summary of the very first post... 
    Summary of the very first post...Summary of the very first post...Summary of the very first post... 
    Summary of the very first post...Summary of the very first post...Summary of the very first post... 
    Summary of the very first post...Summary of the very first post...Summary of the very first post... 
</string> 

Ich will mehr der Inhalt eine Scrollbar jederzeit angezeigt werden, so dass das Datum Textview angezeigt werden kann.

Antwort

1

Um eine Rolle außerhalb einer Karte haben Sie die folgende Struktur verwenden können:

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 
      <!-- your content here --> 
     </LinearLayout> 
    </android.support.v7.widget.CardView> 
</ScrollView> 

Sie eine Rolle innerhalb einer Karte haben, aber in diesem Fall eine Karte immer besetzen den gesamten Bildschirm Höhe auch wenn es nicht viel Inhalt gibt:

<android.support.v7.widget.CardView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 
      <!-- your content here --> 
     </LinearLayout> 
    </ScrollView> 
</android.support.v7.widget.CardView> 
+0

Es funktioniert. Aber wenn ich fragen darf, warum zeigt das Attribut android: scrollbars in der cardview die Scrollbars nicht an, aber für Recyclerviews. –

0

Ich bin nicht sicher, aber wenn das dann nicht funktioniert können Sie wie

LinearLayout 
.... 
...> 
<ScrollView 
..... 
...> 
<CardView 
.... 
....> 
.... 
other views and Viewgroups 
.... 
</CardView 
</ScrollView> 
</LinearLayout> 

Beitrag versuchen, zurück, was Sie bekommen !! Lassen Sie uns wissen

+0

Es funktioniert !!!!!!! –

Verwandte Themen