写真なしでこれを行うにはどうすればよいですか? 自分で描いてみてはどうでしょうか? 2 つの半円、長方形の 4 つの丸い角、および点線を組み合わせてみましょう。
order_pay_shape_left.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#fff"
/>
<!--实现半圆,别想了哥们儿,没哪个属性,用corners设置试一把-->
<corners
android:bottomLeftRadius = "0dp"
android:bottomRightRadius = "19dp"
android:topLeftRadius = "0dp"
android:topRightRadius = "19dp"/>
</shape>
order_pay_shape_right.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#fff"
/>
<corners
android:bottomLeftRadius = "19dp"
android:bottomRightRadius = "0dp"
android:topLeftRadius = "19dp"
android:topRightRadius = "0dp"/>
</shape>
order_details_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!--实现渐变 angle必须是45的倍数 0左到右 90下到上 180右到左 270上到下 -->
<gradient android:startColor="#FFE9CA" android:endColor="#FFDBAC"
android:angle="270"/>
<corners android:radius="4dip"/>
</shape>
order_details_lines.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:color="#F1CB98"
android:width = "0.5dp"
android:dashGap = "2dp"
android:dashWidth = "3dp"/>
</shape>
main_test.xml
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_margin="17dip"
android:background="@drawable/order_details_background"
android:layout_width="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
android:layout_height="202dip">
<TextView
android:layout_marginTop="25dip"
android:textSize="25sp"
android:text="单价:¥500"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_marginTop="70dip"
android:textSize="20sp"
android:text="姓名:张三"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_marginTop="10dip"
android:textSize="16sp"
android:text="地址:北京市朝阳区望京西路225号"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_marginTop="104dip"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<ImageView
android:src="@drawable/order_pay_shape_left"
android:layout_width="34dip"
android:layout_height="35dip" />
<View
android:layout_gravity="center"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:background="@drawable/order_details_lines"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="1dip"/>
<ImageView
android:src="@drawable/order_pay_shape_right"
android:layout_width="34dip"
android:layout_height="35dip" />
</LinearLayout>
</RelativeLayout>
形状の属性についてもう一度理解してみましょう。
固体
説明: 内部パディング
属性: android:color 塗りつぶしの色
サイズ
説明: サイズ
属性:
アンドロイド:幅幅
アンドロイド:身長が高い
勾配
説明: グラデーションカラー
属性:
android:startColor グラデーションの開始色
android:endColor グラデーションの終了色
android:centerColor グラデーションの中間色
android:angle グラデーションの角度。angle=0 の場合、グラデーション カラーは左から右へ、その後反時計回りに回転します。angle=90 の場合、グラデーション カラーは上から下へ進みます。角度は 45 の倍数でなければなりません
android:type グラデーション タイプ: リニア (線形)、ラジアル (放射性、開始色を中心とする)、スイープ (走査線のグラデーション)
LevelListDrawable オブジェクトを使用する場合は、android:userLevel を true に設定する必要があります。グラデーション カラーを持たない場合は true、グラデーション カラーを含む場合は false に設定します。
android:grdientRadial グラデーション半径。この値は、タイプがradialに設定されている場合にのみ有効です。
android:centerX グラデーションの中心 X 点座標の相対位置
android:centerY グラデーションの中心 Y 点座標の相対位置
脳卒中
説明: 脳卒中
属性:
android:width ストローク幅
android:カラーストロークの色
android:dashwidth 破線時のストローク スタイルの幅。値が 0 の場合は実線、値が 0 より大きい場合は破線になります。
android:dashGap ストロークが点線の場合、点線の間隔
コーナー
説明: 丸い角
属性:
android:radius 4 隅の半径の値
android:topLeftRadius 左上隅の半径値
android:topRightRadius 右上隅の半径値
android:bottomLeftRadius 右下隅の半径値
android:bottomRightRadius 左下隅の半径値
パディング
説明: パディング
属性:
アンドロイド:左の左パディング
アンドロイド:右右パディング
android:トップトップパディング
android:ボトムボトムパディング
破線が表示されない、または実線が表示される理由:
1. 表示されない: ビューの高さを点線の高さより大きくすることはできません。ビューの高さを形状の幅の長さよりも大きく設定します。
2. 実線: AndroidManifest.xml で、現在のアクティビティに android:hardwareAccelerated="false" が追加されます。