我想創建一個基於ImageView
自定義視圖,使一個小窗口,如下,其中繪製源是相機和背景是與記號標誌矩形:重力XML繪製
問題是:
- 我無法在右側的刻度線標記上創建邊框:刻度線是全屏拉伸而不是停留在右下角。
- 如果我使用
android:background
來設置刻度,那麼刻度符號會在圖像後面顯示。
這裏是我的xml
文件:
目前的邊境XML繪製
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent"/>
<stroke
android:width="2dip"
android:color="@color/bg_black"/>
<padding
android:left="3dp"
android:right="3dp"
android:top="3dp"
android:bottom="3dp"
/>
</shape>
</item>
<item >
<layer-list >
<item>
<shape
android:shape="rectangle">
<stroke
android:width="2dp"
android:color="@color/border_yellow"/>
<size
android:width="37dp"
android:height="37dp"/>
<padding
android:bottom="3dp"
android:left="3dp"
android:right="3dp"
android:top="3dp"/>
</shape>
</item>
<item android:drawable="@drawable/ic_tick"/>
</layer-list>
</item>
</layer-list>
圖片按鈕XML佈局
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/product1"
android:background="@drawable/toggle_rectangle_check"/>
感謝 你的時間。
你在哪裏使用這個繪製?發佈 – 2015-02-12 02:53:10
@Rod_Algonquin你的意思是佈局xml。我發佈了它。謝謝你的時間。 – thuanle 2015-02-12 03:03:50
我仍然不知道圖像背後的刻度線標記。因爲我想要它在頂部我們可以使用該功能的背景嗎?如果不是我們該如何實現這個功能:自定義'onDraw'函數? – thuanle 2015-02-12 03:07:47