2016-10-14 4 views
-1

は実際に私は、グリッドビューの下にある2つのボタンを設定したいと私は相対的なレイアウトや他のものを試してみたが、問題は設定された2つのボタンが

XMLコード解決されていません。

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:id="@+id/widget" 
    android:layout_height="match_parent"> 
    <include layout="@layout/toolbar" 
     android:id="@+id/toolbar"> 
    </include> 
    <GridView 
     android:id="@+id/gridView1" 
     android:layout_width="363dp" 
     android:layout_height="442dp" 
     android:columnWidth="90dp" 
     android:gravity="bottom" 
     android:layout_weight="1" 
     android:layout_marginTop="70dp" 
     android:layout_below="@+id/toolbar" 
     android:horizontalSpacing="0dp" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="0dp" 
     android:numColumns="2" 
     android:stretchMode="columnWidth" 
     android:verticalSpacing="10dp"></GridView> 



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

enter image description here

答えて

1

が...これはあなたを助けることができる、この希望にしてみてください

<RelativeLayout 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" 
tools:context=".MainActivity"> 

<LinearLayout 
    android:id="@+id/rlListChariTrust" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/ll" 
    android:orientation="vertical"> 

    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/widget" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <include 
      android:id="@+id/toolbar" 
      layout="@layout/toolbar" /> 

     <GridView 
      android:id="@+id/gridView1" 
      android:layout_width="363dp" 
      android:layout_height="442dp" 
      android:layout_below="@+id/toolbar" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="0dp" 
      android:layout_marginTop="70dp" 
      android:layout_weight="1" 
      android:columnWidth="90dp" 
      android:gravity="bottom" 
      android:horizontalSpacing="0dp" 
      android:numColumns="2" 
      android:stretchMode="columnWidth" 
      android:verticalSpacing="10dp" /> 

    </android.support.design.widget.CoordinatorLayout> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/ll" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:orientation="vertical"> 

    <Button 
     android:id="@+id/btn1" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:text="bt1" /> 

    <Button 
     android:id="@+id/btn2" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:text="bt2" /> 

</LinearLayout></RelativeLayout> 
+0

作業thanqqq – techDigi

0
<?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"> 

<!--add ur tool bar here --> 

<!--gride view --> 
<GridView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@id/linearLayout" 
    android:background="@color/colorAccent"></GridView> 

<!--two buttons in LinLay--> 
<LinearLayout 
    android:id="@+id/linearLayout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:orientation="horizontal"> 

    <!--button 1--> 
    <Button 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="button 1" /> 

    <!--button 2--> 
    <Button 
     android:id="@+id/button" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Buttodddn 2" /> 

</LinearLayout> 

</RelativeLayout> 
1

このようにして、Gridviewにフッターを追加すると、より効率的に管理できます。このようにフッターを追加できます。

あなたはこれがあなたの問題を解決するだろうGridViewの下部に追加し、この

View footerView = (LayoutInflater.from(this).inflate(R.layout.footer_layout, null, false); 
GridView.addFooterView(footerView); 

をしたいレイアウトを作成します。

0

enter image description here

<GridLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/gridlayout" 

     android:layout_above="@+id/linear"> 

    </GridLayout> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:id="@+id/linear" 
     android:layout_alignParentBottom="true" 
     android:layout_height="wrap_content"> 

     <Button 
      android:text="Button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button2" 
      android:layout_weight="1" /> 

     <Button 
      android:text="Button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button" 
      android:layout_weight="1" /> 
    </LinearLayout> 
</RelativeLayout> 
関連する問題