1

このようにレイアウトにドットの行を追加する必要があります

ここに画像の説明を入力

これが私のレイアウトです

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/deals_list_item_bckg"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/dealImg"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:scaleType="fitXY"
        android:src="@drawable/deals_list_img" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/dealDescription"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_marginTop="5dp"
            android:maxLines="3"
            android:text="Lorem Ipsum dolor sit amet dolor sed a ite amkt Lantin dolor latim dk kuitshen sed iditur anet" />

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

            <TextView
                android:id="@+id/dealNewPrice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentRight="true"
                android:layout_marginRight="5dp"
                android:text="1248$"
                android:textColor="@color/deals_list_new_price"
                android:textSize="18sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/dealOldPrice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_marginRight="15dp"
                android:layout_toLeftOf="@+id/dealNewPrice"
                android:text="2500$"
                android:textColor="@color/deals_list_old_price"
                android:textSize="15sp" />
        </RelativeLayout>
    </LinearLayout>

</LinearLayout>

どのように私はこのことを行うことができますか? ShapeDrawable も使用してみますが、それがどのように機能するかをまだ理解していません。

4

2 に答える 2

4

これを試して

注:上位バージョンでは、android:layerType属性なしでは機能しません。以下のように値をandroid:layerType持つ属性を追加しますsoftware

android:layerType="software"

詳細については、LAYER_TYPE_SOFTWAREを参照してください。

更新されたレイアウトは次のようになります

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/rounded_edge"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/dealImg"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:scaleType="fitXY"
        android:src="@drawable/ic_launcher" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/dealDescription"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_marginTop="5dp"
            android:maxLines="3"
            android:text="Lorem Ipsum dolor sit amet dolor sed a ite amkt Lantin dolor latim dk kuitshen sed iditur anet" />

        <View
            android:layout_width="match_parent"
            android:layout_height="5dip"
            android:background="@drawable/dash_line"
            android:layerType="software"
            android:orientation="vertical" />

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

            <TextView
                android:id="@+id/dealNewPrice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentRight="true"
                android:layout_marginRight="5dp"
                android:text="1248$"
                android:textColor="@color/scoreColor"
                android:textSize="18sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/dealOldPrice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_marginRight="15dp"
                android:layout_toLeftOf="@+id/dealNewPrice"
                android:text="2500$"
                android:textColor="@color/scoreColor"
                android:textSize="15sp" />
        </RelativeLayout>
    </LinearLayout>

</LinearLayout>

破線はdash_line.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
      android:shape="line" >

       <solid android:color="#fdfdfd" >
        </solid>

      <stroke
          android:dashGap="5px"
          android:dashWidth="5px"
          android:width="2dp"
          android:color="@color/scoreColor" >
      </stroke>

</shape>
于 2014-01-22T11:46:46.833 に答える
3

drawable/dot_repeated.xml

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/dot"
    android:tileMode="repeat" />

レイアウト

...

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/dealDescription"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="5dp"
        android:maxLines="3"
        android:text="Lorem Ipsum dolor sit amet dolor sed a ite amkt Lantin dolor latim dk kuitshen sed iditur anet" />

    <View
        android:layout_width="match_parent"
        android:layout_height="@dimen/dot_height"
        android:background="@drawable/dot_repeated"/>

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

...
于 2014-01-22T11:45:58.580 に答える