語言

Resources.GetDrawableForDensity 方法

定義

多載

名稱 Description
GetDrawableForDensity(Int32, Int32)
已淘汰.

回傳一個可繪製的物件,對應特定資源 ID 並符合 DPI 的螢幕密度。

GetDrawableForDensity(Int32, Int32, Resources+Theme)

回傳一個可繪製的物件,對應特定資源 ID 並符合 DPI 的螢幕密度。

GetDrawableForDensity(Int32, Int32)

警告

deprecated

回傳一個可繪製的物件,對應特定資源 ID 並符合 DPI 的螢幕密度。

[Android.Runtime.Register("getDrawableForDensity", "(II)Landroid/graphics/drawable/Drawable;", "GetGetDrawableForDensity_IIHandler")]
[System.Obsolete("deprecated")]
public virtual Android.Graphics.Drawables.Drawable? GetDrawableForDensity(int id, int density);
[<Android.Runtime.Register("getDrawableForDensity", "(II)Landroid/graphics/drawable/Drawable;", "GetGetDrawableForDensity_IIHandler")>]
[<System.Obsolete("deprecated")>]
abstract member GetDrawableForDensity : int * int -> Android.Graphics.Drawables.Drawable
override this.GetDrawableForDensity : int * int -> Android.Graphics.Drawables.Drawable

參數

id
Int32

由 aapt 工具產生的目標資源識別碼。 此整數編碼套件、類型及資源條目。 值 0 是無效的識別碼。

density
Int32

所需的篩網密度由資源所指示,如 DisplayMetrics。 值為 0 表示使用從 #getConfiguration()返回的密度。 這等同於呼叫 #getDrawable(int)。

傳回

可繪製 一個可以用來繪製此資源的物件。

屬性

例外狀況

如果給定的 ID 不存在,則拋出 NotFoundException。

備註

回傳一個可繪製的物件,對應特定資源 ID 並符合 DPI 的螢幕密度。 此時可繪製密度為裝置密度乘以實際可繪密度與請求密度的比值。 這讓繪製物能在需要時調整到正確的大小。 會根據底層資源回傳不同類型的物件——例如純色、PNG 圖片、可縮放圖片等。可繪製 API 隱藏了這些實作細節。

注意: 要取得有主題的繪製作品,請使用 android.content.Context#getDrawable(int) Context.getDrawable(int) 或 #getDrawableForDensity(int, int, Theme) 傳遞想要的主題。

此會員已被棄用。 請改用 #getDrawableForDensity(int, int, Theme)。

Java 文件 android.content.res.Resources.getDrawableForDensity(int, int)。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

另請參閱

  • <xref:Android.Content.Res.Resources.GetDrawableForDensity(System.Int32%2c+System.Int32%2c+System.Int32)>

適用於

GetDrawableForDensity(Int32, Int32, Resources+Theme)

回傳一個可繪製的物件,對應特定資源 ID 並符合 DPI 的螢幕密度。

[Android.Runtime.Register("getDrawableForDensity", "(IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;", "GetGetDrawableForDensity_IILandroid_content_res_Resources_Theme_Handler")]
public virtual Android.Graphics.Drawables.Drawable? GetDrawableForDensity(int id, int density, Android.Content.Res.Resources.Theme? theme);
[<Android.Runtime.Register("getDrawableForDensity", "(IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;", "GetGetDrawableForDensity_IILandroid_content_res_Resources_Theme_Handler")>]
abstract member GetDrawableForDensity : int * int * Android.Content.Res.Resources.Theme -> Android.Graphics.Drawables.Drawable
override this.GetDrawableForDensity : int * int * Android.Content.Res.Resources.Theme -> Android.Graphics.Drawables.Drawable

參數

id
Int32

由 aapt 工具產生的目標資源識別碼。 此整數編碼套件、類型及資源條目。 值 0 是無效的識別碼。

density
Int32

所需的篩網密度由資源所指示,如 DisplayMetrics。 值為 0 表示使用從 #getConfiguration()返回的密度。 這等同於呼叫 #getDrawable(int)。

theme
Resources.Theme

用於繪製屬性的主題可能是 null。

傳回

可繪製 一個可以用來繪製此資源的物件。

屬性

例外狀況

如果給定的 ID 不存在,則拋出 NotFoundException。

備註

Java 文件 android.content.res.Resources.getDrawableForDensity(int, int)。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於