簡體   English   中英

使用xml旋轉並重復圖像

[英]rotate and repeat image using xml

我想用旋轉設置背景圖像並重復背景圖像。

重復

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

為了輪換

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android" 
    android:fromDegrees="90"
    android:toDegrees="90"
    android:pivotX="50%"
    android:pivotY="50%"
    android:drawable="@drawable/border">

現在我想將這個代碼組合在一個drawable中,並希望用作背景

我這樣想但不行

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

   <rotate xmlns:android="http://schemas.android.com/apk/res/android" 
      android:fromDegrees="90"
      android:toDegrees="90"
      android:pivotX="50%"
      android:pivotY="50%"
      android:drawable="@drawable/border">
</rotate>

</bitmap>

我建議你使用自定義視圖。 我也嘗試過我的動畫背景。 只需使用thread,handler和canvas.scale()方法來旋轉視圖背景。 有一件事我想問。 什么需要設置為背景? 您可以將旋轉drawable設置為背景視圖,並使用透明背景在上面的視圖上執行其他操作。

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="-45"
    android:pivotX="50%"
    android:pivotY="50%">

    <bitmap 
        android:alpha=".5"
        android:src="@drawable/image"
        android:tileMode="repeat" />
</rotate>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM