Thursday, March 21, 2013

[android-developers] Re: I'm missing something dumb here...

Have the imageView's height be fill_parent and its adjustViewBounds set to true, scale_type should be fit_end.
if you dont like the way the image will show, wrap it in a frame_layout/relative_layout that has the Fill_parent and then set its gravity to bottom 



On Wednesday, March 20, 2013 5:53:03 PM UTC+2, Larry Meadors wrote:
I'm making a grid of items that has an image and two text elements under it.

I want all three elements centered horizontally, and the image to be right above the text.

For some reason, the image is centered vertically and the text is at the bottom.

Here's a screen shot to make that clearer:


I've tried everything I can think of...

This is the grid view:

<GridView
  android:id="@+id/content_list_grid_view"
  android:columnWidth="90dp"
  android:numColumns="4"
  android:verticalSpacing="5dp"
  android:horizontalSpacing="10dp"
  android:stretchMode="columnWidth"
  android:layout_height="wrap_content"
  android:layout_width="fill_parent"
  android:padding="5dp"
  />

This is my item:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="140dp"
  android:orientation="vertical"
  android:gravity="bottom|center_horizontal">

  <ImageView
    android:id="@+id/thumbnail_image"
    android:background="#40ff8080"
    android:layout_width="wrap_content"
    android:layout_height="110dp"
    android:layout_gravity="center_horizontal|bottom"
    android:src="@drawable/image_not_available_large"
    android:contentDescription="@string/thumbnail_image" />

  <TextView
    android:id="@+id/title_name"
    android:textColor="@color/white_color"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:gravity="center_horizontal"
    style="@style/normal_label" />

  <TextView
  android:id="@+id/title_author"
  android:textColor="@color/light_gray_color"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:singleLine="true"
  android:gravity="center_horizontal"
  style="@style/normal_label" />

</LinearLayout>


--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment