2016-04-16 14 views
0

次の問題があります。GridViewのコンテンツがデバイスディスプレイに収まらず、スクロールが開始されると、gridviewの下のボタンは表示されません。ボタンがGridViewの下のRelativeLayoutに表示されない

<?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:paddingLeft="16dp" 
android:paddingRight="16dp"> 

    <GridView 
    android:id="@+id/generated_number_gridview" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:columnWidth="90sp" 
    android:horizontalSpacing="10sp" 
    android:stretchMode="columnWidth" 
    android:verticalSpacing="10sp" /> 

    <Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/generated_number_gridview" 
    android:layout_centerHorizontal="true" 
    android:onClick="proceed" 
    android:text="@string/proceed" 
    android:textSize="25sp" /> 
</RelativeLayout> 

は、あなたの助けのために非常に感謝し、次のようになります。

は、ここに私のコードです!

答えて

0

これを試してください。

これをXMLコードに置き換えてください。ここで

<?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:paddingLeft="16dp" 
    android:paddingRight="16dp"> 

    <GridView 
     android:id="@+id/generated_number_gridview" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/btnProceed" 
     android:layout_centerHorizontal="true" 
     android:columnWidth="90sp" 
     android:horizontalSpacing="10sp" 
     android:stretchMode="columnWidth" 
     android:verticalSpacing="10sp" /> 

    <Button 
     android:id="@+id/btnProceed" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:onClick="proceed" 
     android:text="Proceed" 
     android:textSize="25sp" /> 
</RelativeLayout> 

スクリーンショットです。

enter image description here

+0

はい。できます。ありがとうございました ! –

+0

@ Kostya-OniLこれを正解としてマークしてくださいありがとう:) –

0

ボタンレイアウトのプロパティからこの行を削除します。

 android:layout_below="@id/generated_number_gridview" 

これは、GridViewの下にある必要があることを意味します。 GridViewのサイズは固定されていません。レンダラーは、複数の要素を持つGridViewを表示するので、画面がいっぱいになり、ボタンがそれを下回ります。それが目に見えない理由です。

私はこれがあなたが探しているUIだといいと思います。

<?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:paddingLeft="16dp" 
    android:paddingRight="16dp"> 

    <GridView 
     android:id="@+id/generated_number_gridview" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:columnWidth="90sp" 
     android:horizontalSpacing="10sp" 
     android:stretchMode="columnWidth" 
     android:verticalSpacing="10sp" 
     android:layout_above="@+id/proceedButton" 
     /> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentBottom="true" 
     android:id="@+id/proceedButton" 
     android:onClick="proceed" 
     android:text="proceed" 
     android:textSize="25sp" /> 
</RelativeLayout> 

希望します。

+0

はい、それは私が必要なものです。どうもありがとう !このビューが小さすぎて親の開始に合わない場合、GridViewが状況を処理するためにandroid:layout_alignParentTop = "true"と指定したことを追加したいだけです。 –

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:paddingLeft="16dp" 
    android:paddingRight="16dp"> 

    <GridView 
     android:id="@+id/generated_number_gridview" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     **android:layout_above="@+id/btn_proceed"** 
     android:layout_centerHorizontal="true" 
     android:columnWidth="90sp" 
     **android:horizontalSpacing="10dp**" 
     android:stretchMode="columnWidth" 
     **android:verticalSpacing="10dp"** /> 

<Button 
     android:id="@+id/btn_proceed" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:onClick="proceed" 
     android:text="@string/proceed" 
     android:textSize="25sp" /> 
    </RelativeLayout> 
関連する問題