代码之家  ›  专栏  ›  技术社区  ›  Deepan

如何设计这个网格视图xml页面?

  •  -5
  • Deepan  · 技术社区  · 7 年前

    我想设计这种类型的xml页面。 android:numColums=3 , android:verticalSpacing android:horizontalSpacing

    XMl代码:

      <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:tools="http://schemas.android.com/tools"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       xmlns:app="http://schemas.android.com/apk/res-auto"
       tools:context=".MainSettingClass">
    
      <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="175dp"
        android:background="#dadada"
        android:gravity="center"
        android:orientation="vertical">
    
        <ImageView
            android:id="@+id/profile_image"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:src="@drawable/com_facebook_button_background"/>
    
        <TextView
            android:id="@+id/amsc_txt_fbusername"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="TextView"
            android:layout_marginTop="2dp" />
    
       </LinearLayout>
    
      <GridView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/grid_test"
        android:verticalSpacing="2dp"
        android:horizontalSpacing="2dp"
        android:background="#FFFFFF"
        android:stretchMode="columnWidth"
        android:columnWidth="85dp"
        android:numColumns="3"/>
    
      <android.support.design.widget.BottomNavigationView
        android:id="@+id/bottom_gallery"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="#ffffff"
        app:menu="@menu/bottom_navigation_gallery"/>
    
     </FrameLayout>
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   Rucha Bhatt Joshi Ravi Bhushan    7 年前

    scrollview 对于上述2个组件,您的BottomNavigationView是固定的(不可移动)。

    这是我的代码,它完全符合您给定的设计。如果您有任何问题,请尝试使用此代码!:)

    这是我的代码:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <ScrollView
            android:id="@+id/scroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
           android:layout_above="@+id/bottom_gallery">
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">
    
                <LinearLayout
                    android:id="@+id/rel_titleHolder"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="#dadada"
                    android:gravity="center"
                    android:orientation="vertical">
    
                    <ImageView
                        android:id="@+id/profile_image"
                        android:layout_width="100dp"
                        android:layout_height="100dp"
                        android:src="@mipmap/ic_launcher" />
    
                    <TextView
                        android:id="@+id/amsc_txt_fbusername"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="2dp"
                        android:gravity="center"
                        android:text="TextView" />
    
                </LinearLayout>
    
                <GridView
                    android:id="@+id/grid_test"
                    android:layout_width="match_parent"
                    android:layout_height="400dp"
                    android:columnWidth="85dp"
                    android:horizontalSpacing="2dp"
                    android:numColumns="3"/>
            </LinearLayout>
    
        </ScrollView>
    
        <android.support.design.widget.BottomNavigationView
            android:id="@+id/bottom_gallery"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#ffffff"
            android:layout_alignParentBottom="true" />
    
    </RelativeLayout>