当前位置:网站首页>The left sliding menu +menu item icon is grayed out
The left sliding menu +menu item icon is grayed out
2022-06-25 10:09:00 【Peach doesn't come out】
【1】menu item icon The icon is grayed out to solve the problem
As shown above , Because it is navigationview So I'm getting his ID Add after
navigationView.setItemIconTintList(null);
Problem solving , The icon is displayed
【2】 Left slide menu
Refer to the blogger's article :https://blog.csdn.net/s1674521/article/details/62220187
Main activity code :
public class MainActivity extends Activity implements View.OnClickListener {
private DrawerLayout drawerLayout;
private NavigationView navigationView;
private ImageView menu;
private String hhh_item="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
initWindow();
drawerLayout = findViewById(R.id.activity_na);
navigationView = findViewById(R.id.nav);
navigationView.setItemIconTintList(null);
menu= findViewById(R.id.menu);
menu.setOnClickListener(this);
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
//item.setChecked(true);
Toast.makeText(MainActivity.this,item.getTitle().toString(),Toast.LENGTH_SHORT).show();
drawerLayout.closeDrawer(navigationView);
return true;
}
});
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.menu:// Click menu , Jump out of the sideslip menu
if (drawerLayout.isDrawerOpen(navigationView)){
drawerLayout.closeDrawer(navigationView);
}else{
drawerLayout.openDrawer(navigationView);
}
break;
}
}
private void initWindow() {// Initialize window properties , Make the status bar and navigation bar transparent
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
int statusColor = Color.parseColor("#1976d2");
}
}
public void test(View view){
Intent intent=new Intent(MainActivity.this,NewActivity.class);
startActivity(intent);
}
}
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_na"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<include layout="@layout/main_layout"></include>
<android.support.design.widget.NavigationView
android:id="@+id/nav"
android:background="#ffcc99"
android:layout_gravity="left"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:headerLayout="@layout/headlayout"
app:menu="@menu/left_menu"
>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
边栏推荐
- Fluent creates, reads and writes JSON files
- Kotlin advanced generic
- What should be paid attention to in PMP examination?
- 匯付國際為跨境電商賦能:做合規的跨境支付平臺!
- Wallys/MULTI-FUNCTION IPQ6010 (IPQ6018 FAMILY) EMBEDDED BOARD WITH ON-BOARD WIFI DUAL BAND DUAL
- Encoding format for x86
- How to make a self-made installer and package the program to generate an installer
- Is GF Securities reliable? Is it legal? Is it safe to open a stock account?
- Difference between malloc and calloc
- Kotlin keyword and operator
猜你喜欢
Pytorch_Geometric(PyG)使用DataLoader报错RuntimeError: Sizes of tensors must match except in dimension 0.
How to build a wechat applet? How to open an applet?
WPF Prism框架
How much does a wechat applet cost? Wechat applet development and production costs? Come and have a look
How do wechat sell small commodity programs do? How to open wechat apps to sell things?
Flask博客实战 - 实现侧边栏最新文章及搜索
How to "transform" small and micro businesses (II)?
String implementation strstr()
独步武林,架构选型手册(包含 PDF)
CYCA少儿形体礼仪 乐清市培训成果考核圆满落幕
随机推荐
Principle of distribution: understanding the gossip protocol
ShardingSphere-Proxy 4.1 分庫分錶
Guiding principle - read source code
2台三菱PLC走BCNetTCP协议,能否实现网口无线通讯?
Oracle查询自带JDK版本
An auxiliary MVP architecture project quick development library -mvpfastdagger
Shardingsphere proxy 4.1 Sous - base de données sous - table
Force buckle -104 Maximum depth of binary tree
Jetpack compose layout (II) - material components and layout
The problem of wirengpi program running permission
Vscode attempted to write the procedure to a pipeline that does not exist
8. Intelligent transportation project (1)
Request&Response有这一篇就够了
How to make small programs on wechat? How to make small programs on wechat
测试开发工程师
MySQL创建给出语句
Pytorch_ Geometric (pyg) uses dataloader to report an error runtimeerror: sizes of tenants must match except in dimension 0
JS tool function, self encapsulating a throttling function
How do wechat sell small commodity programs do? How to open wechat apps to sell things?
Fluent: target support file /pods runner / pods runner frameworks Sh: permission denied - stack overflow