DroidAwesome
v1.1.9
어떤 관점이나 menuitem에서 fontawesome 아이콘을 표시하는 라이브러리
다음 코드 스 니펫을 module/build.gradle에 추가하십시오
dependencies {
compile ' com.lmntrx.livin.library.droidawesome:droid-awesome:1.1.9 '
}< dependency >
< groupId >com.lmntrx.livin.library.droidawesome</ groupId >
< artifactId >droid-awesome</ artifactId >
< version >1.1.9</ version >
< type >pom</ type >
</ dependency ><? xml version = " 1.0 " encoding = " utf-8 " ?>
< resources >
< string name = " android_icon_font_awesome " >  </ string > //http://fontawesome.io/cheatsheet/
< string name = " not_allowed_font_awesome " >  </ string >
< string name = " fa_settings_gears " >  </ string >
</ resources > <!-- Icons do not render in android studio render sandbox. Run project in an emulator to see changes -->
< com .lmntrx.livin.library.droidawesome.DroidAwesomeAutoCompleteTextView
android : layout_width = " wrap_content "
android : layout_height = " wrap_content "
android : textSize = " 65sp "
android : textColor = " #0f0 "
android : gravity = " center "
android : text = " @string/android_icon_font_awesome " />
< com .lmntrx.livin.library.droidawesome.DroidAwesomeImageView
android : layout_width = " match_parent "
android : layout_height = " wrap_content "
app : text = " @string/not_allowed_font_awesome "
app : textColor = " @color/colorAccent "
app : textSize = " 38sp " /> DroidAwesomeTextView textView = new DroidAwesomeTextView ( context );
textView . setText ( getString ( R . string . your_icon_string ));또는
//TextView, EditText, Button, etc.
TextView textView = new TextView ( context );
textView . setText (
new DroidAwesome . StringBuilder ( this )
. icon ( getString ( R . string . android_icon_font_awesome )) //icon
. build ()
);
//Imageview, ImageButton, FloatingActionButton, etc.
Imageview imageView = new Imageview ( context );
imageView . setImageDrawable (
new DroidAwesome . DrawableBuilder ( this )
. color ( R . color . colorPrimaryDark ) //colorRes
. size ( 75f ) //dimension float (sp)
. icon ( getString ( R . string . fa_settings_gears )) //icon
. build ()
); <!-- XML -->
< menu xmlns : android = " http://schemas.android.com/apk/res/android "
xmlns : app = " http://schemas.android.com/apk/res-auto "
xmlns : tools = " http://schemas.android.com/tools "
tools : context = " com.lmntrx.livin.droidawesome.MainActivity " >
< item
android : id = " @+id/action_settings "
android : orderInCategory = " 100 "
android : title = " @string/action_settings "
/>
</ menu > //Java
@ Override
public boolean onCreateOptionsMenu ( Menu menu ) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater (). inflate ( R . menu . menu_main , menu );
MenuItem menuItem = menu . findItem ( R . id . action_settings );
menuItem . setShowAsAction ( MenuItem . SHOW_AS_ACTION_ALWAYS );
menuItem . setIcon (
new DroidAwesome . DrawableBuilder ( this )
. icon ( getString ( R . string . fa_settings_gears )) //icon
. color ( R . color . colorAccent ) //colorRes
. size ( 25f ) //dimension float (sp)
. build ()
);
return true ;
}Aswin CJ가 설계 한 아이콘
Copyright 2016 DroidAwesome - Livin Mathew
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.