在LinearLayout的最后一个数据中,RecyclerView截止

时间:2018-10-02 09:04:32

标签: android xml layout android-recyclerview scrollview

我有LinearLayout个活动,其中包含2个内容,分别为CardView 1CardView 2。一切顺利,NestedScrollView也是如此。但是我在最后的RecycleView数据中有问题,它在最底端切断了litle位。 我已经尝试过许多我在StackOverflow中搜索过的解决方案,但这仍然做得不好。我是新手,请帮忙

这是我的xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.yehezkiel.eclassapp.MateriActivity"
    >


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


<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler_nilai"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

</LinearLayout>
</LinearLayout>

我的自定义RecyclerView

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="90dp"
    android:background="@color/white"
    android:padding="10dip">


    <TextView
        android:id="@+id/nama_nilai"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_alignWithParentIfMissing="true"
        android:layout_toStartOf="@+id/view_2"
        android:gravity="center_vertical"
        android:text="Pemrogaman Web Tugas 1"
        android:textColor="#5e1b2c"
        android:textSize="16sp"
        android:textStyle="bold" />

    <View

        android:id="@+id/view_2"
        android:layout_width="0.5dp"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentTop="true"
        android:layout_marginEnd="14dp"
        android:layout_toStartOf="@+id/imageView10"
        android:background="#c0c0c0" />

    <TextView
        android:id="@+id/bobot_layout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/imageView8"
        android:textAlignment="center"
        android:layout_marginTop="0.5dp"
        android:ellipsize="end"
        android:gravity="center"
        android:text="Bobot"
        android:textColor="#555555"
        android:textSize="8sp" />

    <ImageView
        android:id="@+id/imageView8"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_alignEnd="@+id/bobot_layout"
        android:layout_below="@+id/nama_nilai"
        android:layout_marginTop="8dp"
        app:srcCompat="@drawable/percentage" />

    <TextView
        android:id="@+id/bobot_nilai"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageView8"
        android:layout_alignTop="@+id/percent"
        android:layout_marginStart="8dp"
        android:layout_toEndOf="@+id/bobot_layout"
        android:text="5.00" />

    <TextView
        android:id="@+id/percent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageView8"
        android:layout_toEndOf="@+id/bobot_nilai"
        android:text="%"
        android:layout_marginStart="2dp"/>

    <ImageView
        android:id="@+id/imageView9"
        android:layout_width="23dp"
        android:layout_height="23dp"
        android:layout_alignBottom="@+id/percent"
        android:layout_marginStart="9dp"
        android:layout_toEndOf="@+id/percent"
        app:srcCompat="@drawable/equality" />

    <TextView
        android:id="@+id/skala_layout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignEnd="@+id/imageView9"
        android:layout_alignStart="@+id/imageView9"
        android:layout_below="@+id/imageView9"
        android:layout_marginTop="1dp"
        android:ellipsize="end"
        android:gravity="center"
        android:text="Skala"
        android:textAlignment="center"
        android:textColor="#555555"
        android:textSize="8sp" />

    <TextView
        android:id="@+id/skala_nilai"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/skala_layout"
        android:layout_marginStart="8dp"
        android:layout_toEndOf="@+id/imageView9"
        android:text="100.00" />

    <ImageView
        android:id="@+id/imageView10"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_below="@+id/nama_nilai"
        android:layout_toStartOf="@+id/nilai_nilai"
        app:srcCompat="@drawable/score" />

    <TextView
        android:id="@+id/nilai_layout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_below="@+id/imageView10"
        android:layout_toStartOf="@+id/nilai_nilai"
        android:ellipsize="end"
        android:text="Nilai"
        android:textAlignment="center"
        android:textColor="#555555"
        android:textSize="12sp" />

    <TextView
        android:id="@+id/nilai_nilai"
        android:layout_width="90dp"
        android:layout_height="50dp"
        android:layout_alignBottom="@+id/nilai_layout"
        android:layout_alignParentEnd="true"
        android:layout_below="@+id/information"
        android:text="89.70"
        android:padding="15dp"
        android:textAlignment="center"
        android:textSize="18sp" />

    <ImageView
        android:id="@+id/information"
        android:layout_width="15dp"
        android:layout_height="15dp"
        android:layout_alignEnd="@+id/nilai_nilai"
        android:layout_alignParentTop="true"
        app:srcCompat="@drawable/information" />


</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

I don't think it's overwritten but I think the textview is hiding behind the card itself since its in a relative layout.

Can you try adding layout below attribute in your cardview and assign the ID of the textview "static1"

Let me know how it goes.