GridView problem with resizing - android

I have a gridview with a button adapter based on this tutorial.
The problem: When sliding up or down, right or left on the gridview, button resize for some reason. e.g from 85*85 px it get's to 100+ on 100+ and when moving finger back it get's to default. I don't really know why this is happening, ive searched alot and didnt find anything. Am I only one who has this bug? I tested it on a real phone too - same.

I would change attributes of GridView and only restrict Button height and see how it behaves
<GridView
android:id="#+id/gridview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numColumns="3"
android:stretchMode="columnWidth"
android:verticalSpacing="5dp"
android:horizontalSpacing="5dp"
/>

Related

My GridView becomes scrollable even if there is much space left on the Page

I am using a simple Linear-Layout with lots of different views and a grid-view. But my problem is that I don't want my grid to be scrollable. I have enough space, at least in my phone and I am also using scroll-view. I just want my grid to not be scrollable, even if it makes my activity too much scrollable.
I can't post whole of my activity because it's too large. So, I am posting only the grid.
If you want anything else, feel free to ask for, I will post that also
<GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/gridview_info"
android:layout_gravity="center_horizontal"
android:numColumns="3"
android:nestedScrollingEnabled="false"
android:layout_weight="1" />
Pls expect late reply.. I am going to sleep and will go to school tomorrow. Will reply only after 6pm (Indian Standard Time)
Thanks in Advance
Change your Gridview property android:layout_height="wrap_content"

Simple way to create display a few dozen icons?

In my app, I want to have some activities that display a series of small images, I'm aiming for 3 per row in portrait and 5 in landscape, but I'm not rigid about those numbers.
The first problem is, I can't figure out a layout, or a configuration of a layout that will allow me to achieve this effect properly. I've tried TableLayout, FrameLayout and RelativeLayouts, but none of them make my images look nicely arranged in both orientations.
In this case the images are flags. I've tried creating 9 Patches out of the ones with symbols in the middle which I don't want to be distorted. Android Studio doesn't pick up that they are .9 files. But that is a separate issue.
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/iceland"
android:layout_weight="0.25"
android:scaleType="fitXY"
android:id="#+id/imageView"/>
I made a mockup of what I'm trying to achieve. I'd really really appreciate any tips you guys can offer. Thanks!
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/gridView1"
android:numColumns="auto_fit"
android:gravity="center"
android:columnWidth="50dp"
android:stretchMode="columnWidth"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</GridView>
taken from this link should deliver an example, that could be useful to you.

Android grid view alignment in a layout

I'm developing a game hangman and it contains A to Z buttons in it everything works fine only problem i'm facing is with the grid view which contains letters from A to Z. When i'm installing the game in mobiles of different screen sizes the grid view consisting of letters are not aligned properly.For small screen mobiles it is enabling scroll automatically and for big screen mobiles it is showing above the bottom margin. I need the grid view to be in fixed position i.e., letters from A to Z should be shown in all types of screen sizes without providing a scroll.The screenshots are below http://tinypic.com/r/2q07otc/8 http://tinypic.com/r/1z1zcwm/8 and my xml code is Please help in solving this so that my assignment completes Thanks in Advance
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="240sp">
<GridView
android:id="#+id/letters"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:horizontalSpacing="5sp"
android:numColumns="9"
android:padding="5sp"
android:stretchMode="columnWidth"
android:verticalSpacing="5sp"
android:layout_marginBottom="5dp" />
</RelativeLayout>
You can try with this android:numColumns="auto_fit" and android:stretchMode.

Changing the Size of my ListView by one Pixel messes up Formatting

Let me show you two links to demonstrate my point:
http://i.snag.gy/QP1i2.jpg (The ListView is 60 pixels)
http://i.snag.gy/DvXsL.jpg (The ListView is 61 pixels)
The whole file is done with an outer Vertical LinearLayout to provide weighted percentages (e.g. the ListView is 75%, the search part is 4%, so on and so forth) independent of device screen size. Within that outer LinearLayout I have a nested Layout (Linear or Relative) depending on my needs for the particular row.
It works beautifully, except for the last part. And it seems a lot of the items I try adding end up messing the formatting so I'm not sure if the problem is how I'm doing the ListView. Anyways, here's the relevant code:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:background="#null"
android:layout_weight="0.75"
android:paddingLeft="0dip" >
<ImageView
android:id="#+id/searchdivider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="2dp"
android:contentDescription="#string/desc"
android:src="#drawable/searchdivider" />
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/searchdivider" >
</ListView>
</RelativeLayout>
Thank you for your help!
EDIT: I should add that I don't want the height to be 60dp, obviously. I want it to fill_parent; however I picked the arbitrary value of 60 and 61 to figure out exactly what change makes the layout mess up.
2nd EDIT: I think I figured out the problem. It seems when I make the Theme AppCompat, it looks and acts fine. But when I make the Theme NoTitleBar (with or without fullscreen) then it acts all screwy. I haven't changed it in the manifest but rather the place in the graphical layout that lets you modify it for that one activity only.
Any suggestions?
android:gravity="left" on imageView and android:gravity="right" on the other listView

How to float multiple Views over a single View in Android

I am trying to figure out a way to float multiple Views over another one, probably either a ListView, or GridLayout. Almost all questions answer with FrameLayout, unfortunately that doesn't work because it was made to float a single View, so that rules it out of the question. I was thinking of using RelativeLayout, but I am having trouble figuring out how to make it work with that. Has anybody been able to figure out a way to do this? Any advice would be much appreciated!
Later children in a RelativeLayout float over earlier children.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="#string/big"
android:textSize="120dip"
android:textStyle="bold"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/small"/>
</RelativeLayout>
The second Button floats over top of the first Button, giving you:
Here is the complete sample project: https://github.com/commonsguy/cw-omnibus/tree/master/Containers/RelativeOverlap.
If I follow what you are asking, it seems like the solutions posted for this seemingly unrelated question might work for your application as well:
Android - How to display a spinner with value but display a different one

Categories

Resources