在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):Yalantis/JellyToolbar开源软件地址(OpenSource Url):https://github.com/Yalantis/JellyToolbar开源编程语言(OpenSource Language):Kotlin 100.0%开源软件介绍(OpenSource Introduction):JellyToolbarCheck this project on dribbble Requirements
UsageAdd to your root build.gradle: allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
} Add the dependency: dependencies {
compile 'com.github.yalantis:jellytoolbar:v1.0'
} How to use this library in your project?First of all, add <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.yalantis.jellytoolbar.widget.JellyToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingStart="@dimen/activity_horizontal_margin"
app:cancelIcon="@drawable/ic_close"
app:endColor="@color/colorEnd"
app:icon="@drawable/ic_search"
app:startColor="@color/colorStart"
app:title="@string/str_news_feed"
app:titleTextColor="@android:color/white" />
</LinearLayout> After that pass an instance of the public class MainActivity extends AppCompatActivity {
private JellyToolbar toolbar;
private AppCompatEditText editText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar = (JellyToolbar) findViewById(R.id.toolbar);
toolbar.getToolbar().setNavigationIcon(R.drawable.ic_menu);
toolbar.setJellyListener(jellyListener);
editText = (AppCompatEditText) LayoutInflater.from(this).inflate(R.layout.edit_text, null);
editText.setBackgroundResource(R.color.colorTransparent);
toolbar.setContentView(editText);
}
private JellyListener jellyListener = new JellyListener() {
@Override
public void onCancelIconClicked() {
if (TextUtils.isEmpty(editText.getText())) {
toolbar.collapse();
} else {
editText.getText().clear();
}
}
};
} To control the animation flow use Override Let us know!We’d be really happy if you sent us links to your projects where you use our component. Just send an email to [email protected] And do let us know if you have any questions or suggestion regarding the animation. P.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for iOS (Android) better than better. Stay tuned! License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论