android - How to make the content of a grid layout stay inside the screen -


i'm developing app, have 100 buttons. , want put buttons inside screen. i'm using gridlayout buttons inside problem having buttons getting out of screen.

this problem having

this code:

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

the question have is: possible do? , best approach?

i made other test changed size of image. result not expected header

result different size image

image other size

as can see in second image buttons in rows inside screen position of buttons not ok, there lot of space between last button of row , end of screen.

the solution looking for, have layout don't allow buttons out of screen, , resizes space between buttons , edges automatically, if screen size different layout automatically adapt size of screen.

i don't think possible. suggest use 6 vertical linearlayouts in 1 horizontal, weight 1 on inner ones. know that not optimized way, it's easiest. keep gridlayout , calculate size of images , set size java code.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -