Tôi đang cố gắng sử dụng xác định biểu tượng tùy chỉnh trong Thanh công cụ hỗ trợ nhưng biểu tượng duy nhất được hiển thị là mũi tên trái ... Tôi đã cố gắng đặt nó trong bố cục và lập trình nhưng kết quả giống nhau .Biểu tượng tùy chỉnh trong thanh công cụ Android
Đây là Hoạt động của tôi
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
toolbar.setNavigationIcon(R.drawable.ic_launcher);
toolbar.setTitle("");
setSupportActionBar(toolbar);
}
Và bố trí thanh công cụ của tôi
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:navigationIcon="@drawable/ic_action_bar"
android:minHeight="@dimen/action_bar_size"
android:background="?attr/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
/>
Bạn nói đúng, nhờ :) – Antoine
Tôi đã trải qua những hành vi tương tự. –
Thay vì 'toolbar.setTitle (" ");', tôi thích sử dụng 'getSupportActionBar(). SetDisplayShowTitleEnabled (false);'. Tôi nghĩ rằng nó sạch hơn rất nhiều. – eoinzy