code

아이콘 세트를 Android Studio 프로젝트로 가져 오는 방법

codestyles 2020. 12. 14. 08:13
반응형

아이콘 세트를 Android Studio 프로젝트로 가져 오는 방법


Android 개발자 센터 에서 아이콘 컬렉션을 다운로드했습니다.이 컬렉션의 각 아이콘은 해상도 (drawable-hdpi, drawable-mdpi, drawable-xhdpi, drawable-xxhdpi)에 따라 이전 형식으로 정렬됩니다.

한 번의 작업으로 4 개의 아이콘 파일을 모두 Android Studio로 가져 오는 방법이 있습니까? 아니면 하나씩 복사해야합니까? (new-> Image Asset을 사용할 때 파일 경로를 채워야하는데 폴더 경로로 채울 수 없었습니다)

업데이트 25/2/15 : 이 질문
에 따르면 Android Asset Studio 에서 4 가지 크기의 아이콘을 생성 한 다음 zip 파일을 Android Studio 프로젝트 res 폴더로 직접 가져 오는 방법이있는 것 같습니다. ?



편집 : Android Studios 1.5 Android 지원 후 Vector Asset Studio .


에 따라 밝히는 :

Vector Asset Studio를 시작하려면 :

  1. Android Studio에서 Android 앱 프로젝트를 엽니 다.
  2. 프로젝트 창에서 Android보기를 선택하십시오.
  3. res 폴더를 마우스 오른쪽 버튼으로 클릭하고 새로 만들기> 벡터 자산을 선택합니다.

여기에 이미지 설명 입력


이전 답변

설정> 플러그인> 저장소 찾아보기> Android Drawable 가져 오기 검색으로 이동하십시오.

이 플러그인은 4 가지 주요 기능으로 구성됩니다.

  1. AndroidIcons 드로어 블 가져 오기
  2. 머티리얼 아이콘 드로어 블 가져 오기
  3. 스케일 드 드로어 블
  4. 다중 소스 그리기 가능

머티리얼 아이콘 드로어 블 가져 오기 사용 방법 : (Android Studio 1.2)

  • 파일> 설정> 기타 설정> Android 드로어 블 가져 오기로 이동합니다.

여기에 이미지 설명 입력

  • Material Icon을 다운로드하고 다운로드 한 경로를 선택하십시오.

여기에 이미지 설명 입력

  • Now right click on project , New > Material Icon Import

여기에 이미지 설명 입력

  • Use your favorite drawable in your project.

여기에 이미지 설명 입력


Actually if you downloaded the icons pack from the android web site, you will see that you have one folder per resolution named drawable-mdpi etc. Copy all folders into the res (not the drawable) folder in Android Studio. This will automatically make all the different resolution of the icon available.


For custom images you created yourself, you can do without the plugin:

Right click on res folder, selecting New > Image Asset. browse image file. Select the largest image you have.

It will create all densities for you. Make sure you select an original image, not an asset studio image with an alpha, or you will semi-transpartent it twice.


If for some reason you don't want to use the plugin, then here's the script you can use to copy the resources to your android studio project:

echo "..:: Copying resources ::.."
echo "Enter folder:"
read srcFolder
echo "Enter filename with extension:"
read srcFile
cp /Users/YOUR_USER/Downloads/material-design-icons-master/"$srcFolder"/drawable-xxxhdpi/"$srcFile" /Users/YOUR_USER/AndroidStudioProjects/YOUR_PROJECT/app/src/main/res/drawable-xxxhdpi/"$srcFile"/
echo "xxxhdpi copied"
cp /Users/YOUR_USER/Downloads/material-design-icons-master/"$srcFolder"/drawable-xxhdpi/"$srcFile" /Users/YOUR_USER/AndroidStudioProjects/YOUR_PROJECT/app/src/main/res/drawable-xxhdpi/"$srcFile"/
echo "xxhdpi copied"
cp /Users/YOUR_USER/Downloads/material-design-icons-master/"$srcFolder"/drawable-xhdpi/"$srcFile" /Users/YOUR_USER/AndroidStudioProjects/YOUR_PROJECT/app/src/main/res/drawable-xhdpi/"$srcFile"/
echo "xhdpi copied"
cp /Users/YOUR_USER/Downloads/material-design-icons-master/"$srcFolder"/drawable-hdpi/"$srcFile" /Users/YOUR_USER/AndroidStudioProjects/YOUR_PROJECT/app/src/main/res/drawable-hdpi/"$srcFile"/
echo "hdpi copied"
cp /Users/YOUR_USER/Downloads/material-design-icons-master/"$srcFolder"/drawable-mdpi/"$srcFile" /Users/YOUR_USER/AndroidStudioProjects/YOUR_PROJECT/app/src/main/res/drawable-mdpi/"$srcFile"/
echo "mdpi copied"

Newer versions of Android support vector graphics, which is preferred over PNG icons. Android Studio 2.1.2 (and probably earlier versions) comes with Vector Asset Studio, which will automatically create PNG files for vector graphics that you add.

The Vector Asset Studio supports importing vector icons from the SDK, as well as your own SVG files.

This article describes Vector Asset Studio: https://developer.android.com/studio/write/vector-asset-studio.html

Summary for how to add a vector graphic with PNG files (partially copied from that URL):

  1. In the Project window, select the Android view.
  2. Right-click the res folder and select New > Vector Asset.
  3. The Material Icon radio button should be selected; then click Choose
  4. Select your icon, tweak any settings you need to tweak, and Finish.
  5. Depending on your settings (see article), PNGs are generated during build at the app/build/generated/res/pngs/debug/ folder.

just like Gregory Seront said here:

Actually if you downloaded the icons pack from the android web site, you will see that you have one folder per resolution named drawable-mdpi etc. Copy all folders into the res (not the drawable) folder in Android Studio. This will automatically make all the different resolution of the icon available.

but if your not getting the images from a generator site (maybe your UX team provides them), just make sure your folders are named drawable-hdpi, drawable-mdpi, etc. then in mac select all folders by holding shift and then copy them (DO NOT DRAG). Paste the folders into the res folder. android will take care of the rest and copy all drawables into the correct folder.


what u need to do is icons downloaded from material design, open that folder there are lots of icons categories specified, open any of it choose any icon and go to this folder -> drawable-anydpi-v21. this folder contains xml files copy any xml file and paste it to this location -> C:\Users\Username\AndroidStudioProjects\ur project name\app\src\main\res\drawable. That's it !! now you can use the icon in ur project.

참고 URL : https://stackoverflow.com/questions/28700593/how-to-import-set-of-icons-into-android-studio-project

반응형