Add toolbar

This commit is contained in:
Alex 2017-08-29 16:02:12 +03:00
parent fde588081d
commit 489e228e3f
2 changed files with 57 additions and 3 deletions

View file

@ -3,14 +3,50 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/map_markers_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_map_toolbar"
android:layout_alignParentTop="true"
android:background="@color/osmand_orange"
android:minHeight="@dimen/dashboard_map_toolbar"
android:theme="?attr/toolbar_theme"
app:contentInsetLeft="54dp"
app:contentInsetStart="54dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:gravity="center_vertical">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/bg_color"> android:layout_weight="1"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:text="@string/map_markers"
android:textColor="@color/color_white"
android:textSize="@dimen/default_list_text_size_large"/>
<ImageButton
android:id="@+id/options_button"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_overflow_menu_white"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_above="@+id/map_markers_bottom_navigation" android:layout_above="@+id/map_markers_bottom_navigation"
android:layout_alignParentTop="true"> android:layout_below="@+id/map_markers_toolbar">
<net.osmand.plus.LockableViewPager <net.osmand.plus.LockableViewPager
android:id="@+id/map_markers_view_pager" android:id="@+id/map_markers_view_pager"
@ -31,6 +67,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:background="?attr/bg_color"
app:itemBackground="?attr/bg_color" app:itemBackground="?attr/bg_color"
app:itemIconTint="@color/bottom_navigation_color_selector" app:itemIconTint="@color/bottom_navigation_color_selector"
app:itemTextColor="@color/bottom_navigation_color_selector" app:itemTextColor="@color/bottom_navigation_color_selector"

View file

@ -7,10 +7,12 @@ import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentPagerAdapter;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Toast;
import net.osmand.plus.LockableViewPager; import net.osmand.plus.LockableViewPager;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -39,6 +41,21 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
View mainView = inflater.inflate(R.layout.fragment_map_markers_dialog, container); View mainView = inflater.inflate(R.layout.fragment_map_markers_dialog, container);
Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.map_markers_toolbar);
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getContext(), "Options", Toast.LENGTH_SHORT).show();
}
});
final LockableViewPager viewPager = mainView.findViewById(R.id.map_markers_view_pager); final LockableViewPager viewPager = mainView.findViewById(R.id.map_markers_view_pager);
viewPager.setSwipeLocked(true); viewPager.setSwipeLocked(true);
viewPager.setAdapter(new MapMarkersViewPagerAdapter(getChildFragmentManager())); viewPager.setAdapter(new MapMarkersViewPagerAdapter(getChildFragmentManager()));