の外観をカスタマイズする:私は内の行リストビューを持っていると思いますどのようにリストビューの列
- は角を丸めています。
- は部分的に着色されています(各行の左側部分)。
- には、別の色で塗りつぶされた色付き領域の形が含まれています。私は現在、2点のリードを持っていますが、私はそれらのいずれかで成功しませんでした
:ここ
は他のアプリからの例です。
私の最初のリード(形状)
私は形状を使用して丸みを帯びた角を取得し、リストビューの背景としてそれを使用する方法を発見しました。
描画可能形状ファイル「rounded_rectangle.xml」:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners
android:bottomRightRadius="7dp"
android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp"/>
</shape>
アクティビティファイル:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent">
// ...
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/splitView"
android:id="@+id/lv_player"
android:layout_alignParentTop="true"
android:background="@drawable/rounded_rectangle"/>
// ...
</FrameLayout>
しかし、私は行が部分的に色の持つ形状を使用する方法がわかりませんまたはアイコンを描画します。私は色で図形を埋めることができますが、行は完全に色付けされています。
私の第2のリード(ベクトル)
また、私は私のリストビューの背景としてベクトルを使用することができることを見出しました。利点は、私がパスを使って欲しいものを描くことができるということです。
ベクトルファイルの例:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="64dp"
android:width="64dp"
android:viewportHeight="600"
android:viewportWidth="600" >
<path
android:name="w"
android:fillColor="#000000"
android:pathData="m 290,103 l-200,0 c -50,0 -50,-100 0,-100 l200,0 z"
/>
</vector>
私は簡単に私の行とアイコンの別の着色領域のパスを作成することができます。しかし、今問題は、ベクトルの大きさを線の大きさに合わせる方法がわかりません。
最適なオプションとは何かを知っていますか?どのようにして期待される結果が得られますか?
ありがとうございます。