Xamarin Android菜单 - NavigationView背景图片和全屏

时间:2018-01-12 11:03:32

标签: android xamarin xamarin.android navigationview android-navigationview

我需要Android中的菜单帮助...

  • 首先:我需要背景中的菜单图片
  • 第二:如果有可能是一个很好的全屏菜单

我的菜单布局如下所示:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:local="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:fillViewport="true">
  <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    >
    <ImageView
      android:id="@+id/nav_background"
      android:src="@drawable/test_back"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:alpha="1"
      android:scaleType="centerCrop"/>
<android.support.design.widget.NavigationView 
                                              android:id="@+id/navigation_view"
                                              android:layout_height="match_parent"
                                              android:layout_width="match_parent"
                                              android:layout_gravity="end"
                                              android:theme="@style/NavigationViewStyle"
                                              android:fitsSystemWindows="true"
                                              local:itemTextColor="@color/white"
                                              android:background="@color/main_red_opacity"
                                             >

  <LinearLayout  android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_gravity="bottom"
                 android:orientation="vertical">
    <LinearLayout  
      android:layout_marginRight="30dp"
      android:layout_marginLeft="30dp"
      android:layout_marginTop="50dp"
      android:layout_marginBottom="50dp"
      android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_gravity="bottom"
                   android:orientation="vertical">
      <TextView
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:textSize="22dp"
        android:id="@+id/nav_menuItem"
        android:text="MenuItem"
        android:textColor="@color/white"
      />
      <TextView
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:textSize="22dp"
        android:id="@+id/nav_menuItem"
        android:text="MenuItem"
        android:textColor="@color/white"
      />
      <ImageView
        android:layout_marginTop="45dp"
        android:layout_marginBottom="45dp"
        android:layout_height="1dp"
        android:layout_width="match_parent"
        android:background="@color/main_gray"
        />
      <TextView
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:textSize="22dp"
        android:id="@+id/nav_menuItem"
        android:text="MenuItem"
        android:textColor="@color/white"
      />
      <TextView
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:textSize="22dp"
        android:id="@+id/nav_menuItem"
        android:text="MenuItem"
        android:textColor="@color/white"
      />
      <TextView
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:textSize="22dp"
        android:id="@+id/nav_menuItem"
        android:text="MenuItem"
        android:textColor="@color/white"
      />

      </LinearLayout>

    <ImageView
      android:layout_gravity="left"
      android:src="@drawable/logo"
      android:layout_width="match_parent"
      android:layout_height="50dp"
      android:id="@+id/logoBottom"
      android:scaleType="fitCenter" />
    </LinearLayout>

</android.support.design.widget.NavigationView>

  </RelativeLayout>
</ScrollView>

这有效,但我需要菜单底部的菜单项布局,但结果是: enter image description here

并且没有ImageView它看起来像这样: enter image description here

我需要这个,但背景中的图像......

修改

  <!-- Navigation style -->
  <style name="NavigationViewStyle">
    <item name="android:textSize">18dp</item>
    <!-- menu item text size-->
    <item name="android:listPreferredItemHeightSmall">60dp</item>
    <!-- menu item height-->
  </style>

Github演示: https://github.com/pinkysek/XabluDemoApp/tree/master/XabluAppTest

1 个答案:

答案 0 :(得分:0)

RelativeLayout更改为FrameLayout

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:local="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:fillViewport="true">
  <FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start"
   android:background="@drawable/test_back"
    >
  </FrameLayout>
</ScrollView>

并在android:layout_marginLeft="-64dp"FrameLayout添加navigation_frame activity_main.axml布局中的<FrameLayout android:id="@+id/navigation_frame" android:layout_height="match_parent" android:layout_width="wrap_content" android:layout_marginLeft="-64dp" android:layout_gravity="left|start" /> ,如下所示:

var qarray = ['canada', 'india', 'america']
var btn = document.querySelector('button');
btn.style.background = 'green';
btn.style.fontSize = '25px';
btn.style.color = 'white';

btn.addEventListener('click', function quotes() {
  var textselect = document.querySelector('h2');

  var one = textselect.textContent = qarray[0];

  btn.addEventListener('click', function quoteone() {
    var two = textselect.textContent = qarray[1];
    btn.addEventListener('click', function() {
      var three = textselect.textContent = qarray[2];
    })
  })
})