-4
我是一名新的Android開發人員。如何在actionbar android中設置背景圖片。如何在actionbar中設置背景圖像android
我可以在我的操作欄中添加圖像背景。但不能縮放我的圖像。
我的風格
<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佈局
個<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>
解決方案
我使用這個庫>>Android-ObservableScrollView