I'm a new Android developer. How to setting background image in actionbar android.
I can add image background within my actionbar. but cant scaling my image.
My style
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
</style>
MainActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LayoutInflater mInflater = LayoutInflater.from(this);
View mCustomView = mInflater.inflate(R.layout.custom_actionbar, null);
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(mCustomView);
}
custom_actionbar layout
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/image" />
</RelativeLayout>
Solutions
I use this Lib >> Android-ObservableScrollView
Please read this article: http://cyrilmottier.com/2013/05/24/pushing-the-actionbar-to-the-next-level/
There you will find example and tutorial about your questuion
And also you can set action bar background like this.
call
setActionBar()
in youroncreate()
.