LoginSignup
6
7

More than 5 years have passed since last update.

【Android】リソースからDrawableを取得する方法

Posted at

取得方法

res/drawable/sample.xmlからdrawableを取得する

java
Drawable drawableButtonNext = ResourcesCompat.getDrawable(getResources(), R.drawable.sample, null);
sample.xml
<?xml version="1.0" encoding="utf-8"?>  
<shape android:shape="rectangle">
    <solid android:color="#000000" />
    <corners android:radius="5dp" />
</shape>
6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7