评级栏没有显示所有五个明星的包装内容和自定义样式不工作的android

时间:2017-09-24 09:16:34

标签: android

我正在尝试显示recyclelerview list中的项目评级。用户可以查看并提供反馈。我尝试过定制的星级颜色和空星的颜色。但它不能正常工作。问题是,所有五颗星都没有显示(4星级显示)。我想自定义明星的选定和空白颜色但这也不起作用。 这是我的适配器代码:

---x--s--x 1 root docker 8448 sept. 24 10:58 /home/docker-proxy-launcher/docker-prestage

这是风格:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_marginTop="5dp">


    <ImageView
        android:layout_width="110dp"
        android:layout_height="110dp"
        android:id="@+id/productImageViewId_deal"
        android:src="@drawable/wad_logo_sparkle"
        android:layout_centerVertical="true"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:fitsSystemWindows="true"
        android:scaleType="fitCenter"
        />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/productTitleTvId_deal"
        android:text="£25,500 FORD GALAXY TITANIUM "
        android:layout_marginLeft="5dp"
        android:textColor="#0e4f71"
        android:layout_toEndOf="@+id/productImageViewId_deal"
        android:textStyle="bold"
        android:textSize="16sp"
        />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/productDescTvId_deal"
        android:text="2.0 5DR HEATED FRONT SEATS, ACTIVE PAR"
        android:layout_marginLeft="5dp"
        android:textColor="#000000"
        android:layout_toEndOf="@+id/productImageViewId_deal"
        android:layout_below="@+id/productTitleTvId_deal"
        android:textSize="14sp"
        />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/productLocTvId_deal"
        android:text=" Ilford, 0, England"
        android:drawableLeft="@drawable/location_icon"
        android:layout_marginLeft="5dp"
        android:textColor="#777"
        android:layout_toEndOf="@+id/productImageViewId_deal"
        android:layout_below="@+id/productDescTvId_deal"
        />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/productPostTimeTvId_deal"
        android:text="May 06, 2016, 12:1914"
        android:layout_marginLeft="5dp"
        android:textColor="#000000"
        android:layout_toEndOf="@+id/productImageViewId_deal"
        android:layout_below="@+id/productLocTvId_deal"
        />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="£25,000.00"
        android:id="@+id/productPriceTvId_deal"
        android:layout_marginLeft="5dp"
        android:paddingBottom="10dp"
        android:textColor="#1470a6"
        android:layout_toEndOf="@+id/productImageViewId_deal"
        android:layout_below="@+id/productPostTimeTvId_deal"
        />

    <RatingBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:max="5"
        android:layout_toEndOf="@+id/productImageViewId_deal"
        android:layout_below="@+id/productPriceTvId_deal"
        android:theme="@style/RatingBar"
        android:layout_marginRight="10dp"
        />

</RelativeLayout>

enter image description here

1 个答案:

答案 0 :(得分:0)

我已经测试了很多方法,最后没有好结果。 您可以使用 function reduceTree(tree) { const getCode = n => n.code; const _reduce = (level = [tree], acc = [[getCode(tree)]], depth = 1) => { const children = level.reduce((a, e) => a.concat(e.children), []); if (!children.length) { return acc; } acc[depth] = children.map(getCode); return _reduce(children, acc, depth + 1); }; return _reduce().reverse(); } reduceTree(tree); /* [ ["A4"], ["A3", "B3"], ["A2", "B2", "C2"], ["A1", "B1", "C1"], ["ROOT"] ] */ 或使用像MaterialRatingBar这样的库。