Note that there are some explanatory texts on larger screens.

plurals
  1. POGridView: How can I get rid of extra space from my GirdView object?
    primarykey
    data
    text
    <p>I'm writing an application for Android phones for Human vs. Human chess play over the internet. I was looking at some tutorials, to learn how to develop Android applications and found a very nice example of making galleries (it was a GridView usage example for making a gallery about dogs) and the idea came to draw the chess table using a GridView, because the example project also handled the point &amp; click event and I intended to use the same event in the same way, but for a different purpose. The game works well (currently it's a hotseat version), however, I'm really frustrated by the fact that whenever I rotate the screen of the phone, my GridView gets hysterical and puts some empty space in my chess table between the columns. I realized that the cause of this is that the GridView's width is the same as its parent's and the GridView tries to fill its parent in with, but there should (and probably is) be a simple solution to get rid of this problem. However, after a full day of researching, I haven't found any clue to help me to make a perfect drawing about my chess table without a negative side effect in functionality. The chess table looks fine if the phone is in Portrait mode, but in Landscape mode it's far from nice. This is how I can decide whether we are in Portrait or Landscape mode:</p> <pre><code>((((MainActivity)mContext).getWindow().getWindowManager().getDefaultDisplay().getWidth()) &lt; ((MainActivity)mContext).getWindow().getWindowManager().getDefaultDisplay().getHeight()) </code></pre> <p>In the main.xml file the GridView is defined in the following way:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gridview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:numColumns="8" android:verticalSpacing="0dp" android:horizontalSpacing="0dp" android:stretchMode="columnWidth" android:gravity="center" &gt; &lt;/GridView&gt; ... &lt;/LinearLayout&gt; </code></pre> <p>I appreciate any help with the problem and thank you for reading this.</p> <p>Portrait: <a href="http://www.freeimagehosting.net/image.php?f388b3ec64.png" rel="nofollow noreferrer">http://www.freeimagehosting.net/image.php?f388b3ec64.png</a></p> <p>Landscape: <a href="http://www.freeimagehosting.net/image.php?ee790603a2.png" rel="nofollow noreferrer">http://www.freeimagehosting.net/image.php?ee790603a2.png</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload