사용자가 레이아웃에 들어갈 때 "DrawerLayout"을 잠시 표시해야합니다.
-
21-12-2019 - |
문제
원하는 것은 왼쪽에 숨겨진 바를 표시하는 것입니다. 사용자가 레이아웃에 들어가면 아이디어가 그 존재를 신호하는 액션 바에 아이콘을 넣지 않고도 막대가 있음을 알고 있습니다
해결책
활동이 처음 생성 될 때 처음으로 탐색 드로너를 열려면 다음과 같이 할 수 있습니다.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_drawer_activity);
drawer = (ListView) findViewById(R.id.left_drawer); // the drawer itself (ListView for example)
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); // the drawer layout itself
drawerLayout.openDrawer(drawer);
}
.
XML은 다음과 같이 보일 수 있습니다 :
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/background_activity_color">
<!-- The main content view -->
<FrameLayout
android:id="@+id/fragmentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The navigation drawer -->
<ListView
android:id="@+id/left_drawer"
android:layout_width="250dp"
android:layout_height="match_parent" />
</android.support.v4.widget.DrawerLayout>
. 제휴하지 않습니다 StackOverflow