誰かが私を助けてくれるだろうかと思っています。異なる画面密度で表示するときにカスタム RatingBar を操作すると、スケーリングの問題が発生します。私の問題を説明するために簡単なサンプル プロジェクトを設定しました。これは、密度に関係なく、現時点では大画面サイズにのみ関係する非常に基本的なプロジェクトです。
画像からわかるように、RatingBar に使用するセレクターがあり、高密度のドローアブル フォルダーのそれぞれに 2 つの個別の RatingBars のデフォルト イメージとフル イメージがあります (すべてのイメージは今のところ同じサイズです)。このカスタム RatingBar を表示するため。これらの評価バーを正しく表示しようとしましたが、以下に概説するように、2 つの別々の方法を試しました。以下に示すように、レイアウト ファイルで RatingBars の幅と高さを指定しようとした最初の方法:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RatingBar
android:id="@+id/rb_test_1"
android:numStars="1"
android:rating="0.5"
android:stepSize="0.01"
android:isIndicator="true"
android:layout_width="150dp"
android:layout_height="111dp"
android:layout_gravity="bottom"
android:gravity="bottom"
android:progressDrawable="@drawable/selector_rb_test_1" />
<RatingBar
android:id="@+id/rb_test_2"
android:numStars="1"
android:rating="0.5"
android:stepSize="0.01"
android:isIndicator="true"
android:layout_width="200dp"
android:layout_height="154dp"
android:layout_gravity="bottom"
android:gravity="bottom"
android:progressDrawable="@drawable/selector_rb_test_2" />
</LinearLayout>
GUI のグラフィカル レイアウトを見ると、基本的な 10.1 画面サイズと Nexus 10 で表示される次の出力が生成されます。画像を複製して引き伸ばしているようです。
ここで、2 番目の方法を試してみます。これは、私がやりたい方法に似ています (RatingBars のそれぞれの正確なサイズを指定する必要がなく、レイアウトの幅と高さをラップするように設定するだけで、次のようになります)。コード:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RatingBar
android:id="@+id/rb_test_1"
android:numStars="1"
android:rating="0.5"
android:stepSize="0.01"
android:isIndicator="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="bottom"
android:progressDrawable="@drawable/selector_rb_test_1" />
<RatingBar
android:id="@+id/rb_test_2"
android:numStars="1"
android:rating="0.5"
android:stepSize="0.01"
android:isIndicator="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="bottom"
android:progressDrawable="@drawable/selector_rb_test_2" />
</LinearLayout>
GUI のグラフィカル レイアウトを見ると、基本的な 10.1 画面サイズと Nexus 10 で表示される次の出力が生成されます。これにより、RatingBar の画像の下部が切り取られます。
画面の密度に関係なく、問題なく複数の評価バーを表示できるようにするだけです。Nexus10の画面で表示が異なる理由とその修正方法を誰かが理解するのを手伝ってくれますか? 私はしばらくこれに固執しており、誰かが光を当てることができれば非常にうれしい. 事前にどうもありがとうございました。