2017-08-02 36 views
-5

我想要設計這種類型的xml頁面。 我嘗試了許多代碼。每當新問題出現時。我需要底部的導航欄是固定的。在網格視圖中,我想要android:numColums=3,android:verticalSpacingandroid:horizontalSpacing相同(看起來像instagram個人資料查看網格圖像)。如何設計這個Grid view xml頁面?

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> 
+0

你做了什麼? –

+0

_I嘗試了許多代碼..._您的代碼在哪裏? –

+0

顯示你爲實現目標所做的努力? – Akshay

回答

1

根據你的設計,你需要scrollview 2以上的組件,並且你BottomNavigationView是固定(不可移動)。

在你的代碼中,你沒有使用scrollview第一和第二我不知道你爲什麼使用framelayout!

這裏是我的代碼,這是完全按照您給定的設計試試這個,如果任何問題,你可以問! :)

這裏是我的代碼:

<?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> 
+1

爲什麼OP要「試試這個」?一個好的答案**將總是解釋所做的事情以及爲什麼這樣做,不僅是爲了OP,而且是爲了將來SO的訪問者。 –

+1

@bub謝謝你的指導,我會確保這.. .. P.S檢查我已經做了! :) –