gpt4 book ai didi

Android Material Design 抽屉导航菜单图标更改

转载 作者:行者123 更新时间:2023-11-29 17:35:14 25 4
gpt4 key购买 nike

我使用 this 实现了 Material Design 抽屉导航例子。我根据我的主题定制它。一切都运行良好。我最不想自定义的是它的菜单图标。我用谷歌搜索,但没有找到任何好的解决方案。如果可能的话,我想改变它的颜色,或者添加一个自定义的可绘制对象。关于想法的任何解决方案。提前致谢 enter image description here

这是我在 list 中设置的应用程序主题

<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColorPrimary">@color/textColorPrimary</item>
<item name="android:windowBackground">@color/windowBackground</item>

</style>

这是我的工具栏样式

<

style name="GalaxyZooThemeToolbarDarkOverflow" parent="Theme.AppCompat.NoActionBar">
<item name="android:textColorPrimary">@color/headerColor</item>
<item name="android:iconPreview">@drawable/ic_launcher</item>

<item name="actionMenuTextColor">@color/colorPrimaryDark</item>
<item name="android:textColorSecondary">@color/headerColor</item>

我的主要 Activity 代码

public class Activity_Home extends ActionBarActivity implements FragmentDrawer.FragmentDrawerListener {

private static String TAG = Activity_Home.class.getSimpleName();

private Toolbar mToolbar;
private FragmentDrawer drawerFragment;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_drawer);

mToolbar = (Toolbar) findViewById(R.id.toolbar);

setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayShowHomeEnabled(true);


drawerFragment = (FragmentDrawer)
getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer);
drawerFragment.setUp(R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), mToolbar);
drawerFragment.setDrawerListener(this);

// display the first navigation drawer view on app launch
displayView(0);
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity__main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
//
// if(id == R.id.action_search){
// Toast.makeText(getApplicationContext(), "Search action is selected!", Toast.LENGTH_SHORT).show();
// return true;
// }

return super.onOptionsItemSelected(item);
}

@Override
public void onDrawerItemSelected(View view, int position) {
displayView(position);
}

private void displayView(int position) {

}
}

最佳答案

添加:

getSupportActionBar().setHomeAsUpIndicator(resId);

getSupportActionBar().setHomeAsUpIndicator(drawable);

到您的ActivityonCreate

关于Android Material Design 抽屉导航菜单图标更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30775024/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com