2016-04-18 4 views
1

私はグリッドビューの行にレーティングバーを表示しようとしていますが、レーティングバーの上に常に黒いオーバーレイがあります。グリッドビューの行が1行しかない場合は、評価バーは完璧に表示されます。しかし、グリッドビューに複数の行がある場合は、常にレーティングバーの上に黒いオーバーレイが表示されます。だから私はこの問題をどのように解決するのですか?そして、それはロリポップデバイスでのみ起こっているようです。Ratingbarはグリッドビューに黒いオーバーレイを表示しています

私のGridViewの:私のコードを以下に示す

<UI.ExpandableHeightGridView 
       android:id="@+id/gridview_agent_reviews" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="5dp" 
       android:horizontalSpacing="2dp" 
       android:isScrollContainer="false" 
       android:numColumns="1" 
       android:stretchMode="columnWidth" /> 

私のGridViewの行:

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

<View 
    android:layout_width="match_parent" 
    android:layout_height="0.5dp" 
    android:layout_marginBottom="5dp" 
    android:background="#cccccc" /> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="5dp" 
    android:layout_marginTop="5dp"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_toLeftOf="@+id/img_review_flag" 
     android:layout_toStartOf="@+id/img_review_flag" 
     android:orientation="horizontal"> 

     <TextView 
      android:id="@+id/lbl_review_date" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginEnd="5dp" 
      android:layout_marginRight="5dp" 
      android:text="2016-04-05" 
      android:typeface="sans" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginEnd="5dp" 
      android:layout_marginRight="5dp" 
      android:text="|" 
      android:typeface="sans" /> 

     <TextView 
      android:id="@+id/lbl_review_name" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginEnd="5dp" 
      android:layout_marginRight="5dp" 
      android:text="Recommendation by John Doe" 
      android:typeface="sans" /> 
    </LinearLayout> 

    <ImageView 
     android:id="@+id/img_review_flag" 
     android:layout_width="22dp" 
     android:layout_height="22dp" 
     android:layout_alignParentEnd="true" 
     android:layout_alignParentRight="true" 
     android:layout_marginRight="5dp" 
     android:src="@drawable/ic_flag_blue" /> 
</RelativeLayout> 

<View 
    android:layout_width="match_parent" 
    android:layout_height="0.5dp" 
    android:layout_marginBottom="5dp" 
    android:layout_marginTop="5dp" 
    android:background="#cccccc" /> 

<RatingBar 
    android:id="@+id/rate_review" 
    style="@style/CustomRatingBar" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:isIndicator="true" /> 

<View 
    android:layout_width="match_parent" 
    android:layout_height="0.5dp" 
    android:layout_marginBottom="5dp" 
    android:layout_marginTop="5dp" 
    android:background="#cccccc" /> 

<TextView 
    android:id="@+id/lbl_review_text" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Congrats! Keep up the great work." 
    android:textColor="#000" 
    android:typeface="sans" /> 

</LinearLayout> 

そして、私のアダプタでの私のgetViewメソッド:

@Override 
public View getView(int i, View view, ViewGroup viewGroup) { 
    View v = view; 
    ViewHolder holder; 
    try { 

     if (v == null) { 
      LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      v = inflater.inflate(R.layout.row_list_agent_review, null); 
      holder = new ViewHolder(); 
      holder.lblReviewDate = (TextView) v.findViewById(R.id.lbl_review_date); 
      holder.lblReviewer = (TextView) v.findViewById(R.id.lbl_review_name); 
      holder.lblReviewDesc = (TextView) v.findViewById(R.id.lbl_review_text); 
      holder.ReviewRate = (RatingBar) v.findViewById(R.id.rate_review); 
      v.setTag(holder); 

     } else { 
      holder = (ViewHolder) v.getTag(); 
     } 

     String []Date=list.get(i).CreateDate.split("T"); 
     holder.lblReviewDate.setText(Date[0]); 
     holder.lblReviewer.setText("Recommendation by "+list.get(i).FirstName+" "+list.get(i).LastName); 
     holder.lblReviewDesc.setText(list.get(i).RecommendationInfo); 
     holder.ReviewRate.setRating(Float.valueOf(list.get(i).RatingScale)); 

    }catch (Exception e){ 


    } 

    return v; 
} 

のスクリーンショット問題:

:複数行

GridView with multiple rows

GridViewの

GridView with 1 row

編集

私のスタイルのXML列1として3210 のGridView

<style name="CustomRatingBar" parent="@android:style/Widget.RatingBar"> <item name="android:progressDrawable">@drawable/ratingbarcustom</item> <item name="android:minHeight">32dip</item> <item name="android:maxHeight">32dip</item> </style> 

ratingbarcustom.xml

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:id="@android:id/background" 
    android:drawable="@drawable/rating_bar_empty" /> 
<item android:id="@android:id/secondaryProgress" 
    android:drawable="@drawable/rating_bar_empty" /> 
<item android:id="@android:id/progress" 
    android:drawable="@drawable/rating_bar_filled" /> 
</layer-list> 

ratingbarempty.xml:

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:drawable="@drawable/star_outline" android:state_pressed="true" android:state_window_focused="true"/> 
<item android:drawable="@drawable/star_outline" android:state_focused="true" android:state_window_focused="true"/> 
<item android:drawable="@drawable/star_outline" android:state_selected="true" android:state_window_focused="true"/> 
<item android:drawable="@drawable/star_outline"/> 
</selector> 

ratingbarfull.xml:

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:drawable="@drawable/star_full" android:state_pressed="true"  android:state_window_focused="true"/> 
<item android:drawable="@drawable/star_full" android:state_focused="true" android:state_window_focused="true"/> 
<item android:drawable="@drawable/star_full" android:state_selected="true" android:state_window_focused="true"/> 
<item android:drawable="@drawable/star_full"/> 
</selector> 
+0

あなたのstyle.xmlを共有してください。 –

+0

@PradeepGupta私は自分の質問を更新しました。見てください。 –

+0

セレクタを使用してレーティングバーを選択および選択解除する必要はありません。あなたはratingbarcustom.xmlにあなたの画像を設定しなければなりません。 –

答えて

1

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:id="@android:id/background" 
    android:drawable="@drawable/star_outline" /> 
<item android:id="@android:id/secondaryProgress" 
    android:drawable="@drawable/star_outline" /> 
<item android:id="@android:id/progress" 
    android:drawable="@drawable/star_full" /> 
</layer-list> 
、これを試してみてください
+1

うまくいかない。私の評価バーには複数の行の黒いオーバーレイが残っています。私はAPIレベル16のgenymotionエミュレータでテストしました。評価バーは完璧に表示されています。しかし、実際のデバイスには黒のオーバーレイがあります。 –

関連する問題