-1

私は100個のボタンを持つアプリを開発しています。そして、私はすべてのボタンを画面の中に入れたい。私が持っている問題の中のすべてのボタンでGridLayoutを使用していますが、ボタンが画面から外れているということです。グリッドレイアウトの内容を画面内に残す方法

This is the problem that I am having

これはコードです:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/content_main" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context=".MainActivity" 
    tools:showIn="@layout/app_bar_main" 
    android:layout_column="1"> 

<GridLayout 
    android:id="@+id/GridLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:columnCount="6" 
    android:rowCount="17" 
    android:orientation="vertical"> 

    <ImageButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     app:srcCompat="@drawable/numero_1" 
     android:id="@+id/button1"/> 

私が持っている質問がされています。これは何をすることは可能ですか?これが最善のアプローチですか?

イメージのサイズを変更した他のテストを行いました。結果は、あなたが行のボタンが画面内にある第二の画像が、ボタンの位置で見ることができるように私は、異なるサイズの画像

Image with other size

とヘッダ

の検索結果を期待したものではありませんOKではない、行の最後のボタンと画面の最後の間には多くのスペースがあります。

私が探している解決策は、ボタンが画面から外れることを許さず、画面サイズが異なる場合、ボタンとエッジの間のスペースを自動的にサイズ変更するレイアウトですレイアウトは自動的に画面のサイズに適応します。

答えて

0

私はそれが可能ではないと思います。 1つの水平線に6つの垂直LinearLayoutsを使用し、内側には1を使用することをお勧めします。私はそれが最も最適化された方法ではないことを知っていますが、それは最も簡単です。もう一つは、GridLayoutを保持し、イメージのサイズを計算し、Javaコードからサイズを設定することです。

関連する問題