gpt4 book ai didi

java - 抽屉导航中的 3 行图标未动画化为较小的图像

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:38:48 26 4
gpt4 key购买 nike

logo 旁边的小图标(指示器或 3 行)没有变小。

What i want is this --> 此图像没有动画效果,当我单击应用程序的 Logo 时,抽屉已打开,但图像未动画化为更小的图像,这表明抽屉当前已打开。

gABar.get().setDisplayHomeAsUpEnabled(true);

 mDrawerToggle = new ActionBarDrawerToggle(
getActivity(), /* host Activity */
mDrawerLayout.get(), /* DrawerLayout object */
R.drawable.ic_drawer2, /* nav drawer image to replace 'Up' caret */
R.string.drawer_open, /* "open drawer" description for accessibility */
R.string.drawer_close /* "close drawer" description for accessibility */
) {
@Override
public void onDrawerClosed(View view) {
getActivity().getActionBar().setTitle(mTitle);
getActivity().invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()

Log.d("onDrawerClosed", "inside");
}

@Override
public void onDrawerOpened(View drawerView) {
getActivity().getActionBar().setTitle(mDrawerTitle);
getActivity().invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
}

};

@Override
public boolean onOptionsItemSelected(MenuItem item)
{
int id = item.getItemId();
Log.d("item ID : ", "onOptionsItemSelected Item ID" + id);
if (id == android.R.id.home) {


return true;

} else {
return super.onOptionsItemSelected(item);
}
}

最佳答案

请确保将此行放入声明 ActionBarDrawerToggle 的代码中:

mDrawerLayout.setDrawerListener(mDrawerToggle);

正如你在这个例子中看到的:

public class MyActivity extends ActionBarActivity  {

private DrawerLayout mDrawerLayout;
private ListView mDrawerList;
private ActionBarDrawerToggle mDrawerToggle;
private String[] menuitems;

@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
menuitems = getResources().getStringArray(R.array.optionsname);

MyDrawerAdapter draweradapter = new MyDrawerAdapter(getApplicationContext(), menuitems);
mDrawerList.setAdapter(draweradapter);

mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_navigation_drawer, R.string.drawer_open, R.string.drawer_close) {

public void onDrawerClosed(View view) {
invalidateOptionsMenu();
}

public void onDrawerOpened(View drawerView) {
invalidateOptionsMenu();
}

@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
super.onDrawerSlide(drawerView, slideOffset);
mDrawerLayout.bringToFront();
mDrawerLayout.bringChildToFront(drawerView);
mDrawerLayout.requestLayout();
mDrawerLayout.invalidate();
}
};

mDrawerLayout.setDrawerListener(mDrawerToggle);

mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setIcon(new ColorDrawable(0x00000000));
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(0xffffffff));
}
}

如果您忘记将 drawerlistener 添加到 drawerlayout,它不会为您的抽屉图标设置动画。

关于java - 抽屉导航中的 3 行图标未动画化为较小的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19829455/

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