layout_width="wrap_parent" in GridView does not work as I expect

by Mark Murphy » Fri, 26 Sep 2008 13:21:37 GMT


Sponsored Links
 


Possibly by default android:stretchMode behaves as "AUTO_FIT".

Try android:stretchMode="NO_STRETCH", or possibly android:stretchMode=" 
STRETCH_COLUMN_WIDTH" or "STRETCH_SPACING", in your layout XML for your 
GridView, to see if one of those settings is more to your liking.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
Warescription: All titles, revisions, & ebook formats, just $35/year

--~--~---------~--~----~------------~-------~--~----~



layout_width="wrap_parent" in GridView does not work as I expect

by Kah0ona » Fri, 26 Sep 2008 13:28:19 GMT


 Hello,

Not entirely sure if such questions belong here, but anyways.

I have a simple main.xml file with a GridView inside a LinearLayout
(orientation=vertical). The GridView has numColumns specified at 3 and
there are exactly 9 objects in the grid, creating a 3x3 matrix, where
each columnWidth is fixed at 30dp. Both layout_height and _width are
specified as "wrap_content".

Under the gridview is a simple TextView with a hardcoded string in it.

Now on the bottom this wrap_content works; i can tell by putting a
different background color, to see the edges of the gridview. But on
the right side, it fills up to fill the screen, as if fill_parent was
specified! What am I doing wrong here? What is the reason that it
doesn't wrap the content horizontally, but it DOES vertically?

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


layout_width="wrap_parent" in GridView does not work as I expect

by Kah0ona » Fri, 26 Sep 2008 17:31:52 GMT


 hm that didn't work... I kind of refuse to use a hardcoded width,
which works, but is sub-optimal...

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Is there an easy way to make EditText look like TextView but still behave like EditText?

Note: I had troubles posting to android-beginners group, so I came here
hoping this will work.

Hello there,

I want an EditText to look like TextView but still behave like
EditText. I've tried applying TextView style to my EditText in my
layout.xml file, like this:

<EditText
       android:id="@+id/lipsum"
       android:text="Lorem ipsum"
       android:style="@android:style/Widget_TextView"
/>

..but I get an error within xml editor: "Error: No resource found that
matches the given name (at 'style' with value '@android:style/
Widget_TextView')." It is strange because @android:style/
Widget_TextView definitively exists - I double checked it in code via
android.R.style.Widget_TextView. Another strange thing is that I don't
get android:style offered in the xml editor while typing? There is
android:id, android:text and everything else.. but not
android:style?!

Note: I consider the hard way (making EditText look like TextView) to
be: extending EditText and overriding it's onDraw method.

Nikolar

PS: Check out
http://developer.android.com/guide/topics/ui/themes.html#styles.
Why are id and style written without android: namespace?

--~--~---------~--~----~------------~-------~--~----~

2. Is there an easy way to make EditText look like TextView but still behave like EditText?

Try this:
        android:style="@android:style/Widget.TextView"

R/

On Sun, May 17, 2009 at 3:31 PM, Nikola Radosavljevic



--~--~---------~--~----~------------~-------~--~----~

3. Multiline text input

4. Porting Qt applications on Android

5. WebView scroll issue while loading a website

6. react to SCREEN_ON, but only when user pressed a button

7. Auto-IP is not supported