我需要把我自己的圖像放在一些imageView
上。所以這就是爲什麼我在res文件夾中創建了名爲「drawable」的文件夾,並將該圖像複製到此文件夾中,但現在我不知道如何將此圖像設置爲以XML代碼形式的imageView
。任何人都可以幫忙嗎?和遺憾,對英語:)如何在ImageView中設置圖像?
1
A
回答
3
在您的佈局XML文件:採用了android它
1
//設置調用android:background
屬性在你的XML
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/myimage"
/>
注意背景圖像:你不需要創建默認的Android項目的任何繪製文件夾將包含
drawable-mdpi
drawable-hdpi
drawable-ldpi
你可以把你的形象在那。 SRC = 「」
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/image_name" />
2
集
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/your_image_name"/>
更換your_image_name
與圖像文件的名稱不帶擴展名(例如,如果您繪製文件被稱爲img1.png
,src
屬性應具有值@drawable/img1
)。
1
試試這個。
<ImageView
android:id="@+id/YourImageViewID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/Your_Image_Name"
/>
這可能對你有幫助。
0
<ImageView
android:layout_width="150dp"
android:layout_gravity="bottom"
android:layout_height="150dp"
android:id="@+id/image1"
android:layout_marginTop="11dp"
android:background="@drawable/image1"
/>
相關問題
- 1. 如何在Android ImageView中設置圖像
- 2. 在imageView中設置圖像
- 3. 在imageview中設置圖庫的圖像
- 4. 如何設置圖像.BMP到ImageView的
- 5. 如何從庫中設置imageview的圖像,然後單擊imageview?
- 6. 在imageView數組中設置圖像?
- 7. 如何在Android中的ListView中的imageview中設置圖像?
- 8. 從url設置imageview圖像
- 9. Android ImageView設置圖像源
- 10. 如何在android中設置imageview中的圖像?
- 11. 如何在ImageView中設置在運行時決定的圖像?
- 12. 如何通過imageview將圖像背景設置爲imageView View?
- 13. 如何在ios中生成imageview後設置圖像?
- 14. 如何通過URL在ImageView中設置圖像Android
- 15. 如何在Android的Imageview中設置BLOB圖像?
- 16. android:如何使用計數器在imageview中設置圖像?
- 17. android - 如何在ImageView中將圖像設置爲正確比例
- 18. 如何在android的webview中的imageview上設置圖像
- 19. 如何在imageview swift 3中設置圖像?
- 20. 如何判斷ImageView在android中是否有設置的圖像?
- 21. JavaFx ImageView設置中心圖像
- 22. 如何在imageActivityResult中獲取圖像位圖並在imageview中設置圖像後刪除圖像
- 23. 如何在imageview上設置imageview?
- 24. 如何將圖像設置爲Xamarin中ListView內的ImageView?
- 25. 如何將viewFlipper的imageView中的圖像設置爲壁紙?
- 26. 如何設置Android中特定文件的imageview圖像?
- 27. 如何檢查ImageView中設置的圖像
- 28. 如何在imageview上設置捕獲的圖像
- 29. 如何知道在ImageView上設置了哪個圖像?
- 30. 如何從圖庫中獲取圖像並在ImageView中設置(擴展Fragment)?
正如我試過的,我不能使用類型爲.png的圖像,但它使用.jpg。非常感謝:) –
@HaykNahapetyan不,你也可以使用JPG圖片,你需要檢查圖片名稱的命名轉換。 –
哦,對不起,我犯了一些其他的錯誤,這就是爲什麼我這麼認爲:),非常感謝 –