开发者

how to place a line of text below the end of grid

I have a task to show images in grid ,i got the view what i needed but i have to place click here to view more.. at bottom.

Here i'm facing problem to place the text below image has a common, for example,each row have three images in grid and it looks:

    ----------------------
   | img1   img2   img3
   | img4    ...   ...
   | 
   | click here to view more..

after img3, img4 in next row in the grid

How can i place text in the view has like above?

here my code for imageview.xml:

<RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="100dip" android:background="@color/white"
    android:layout_height="80dip" xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_gravity="center_horizontal">
    <ImageView android:id="@+id/jr_lb_list_icon" android:layout_width="60dip" android:layout_height="65dip"
               android:scaleType="fitCenter" android:background="@drawable/border"
              android:layout_centerInParent="true" />

</RelativeLayout>

here my co开发者_如何学Gode for imageview.xml:

<merge android:layout_width="wrap_content" android:layout_height="340dip" xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
  <GridView 
                    android:id="@+id/jr_lookbook_grid" android:layout_width="fill_parent"
                    android:layout_height="320dip" android:numColumns="4"
                    android:verticalSpacing="10dp" android:horizontalSpacing="10dp"
                    android:columnWidth="90dp" android:stretchMode="columnWidth"
                    android:adjustViewBounds="true"
                    android:background="@drawable/shape"            
                    android:gravity="center"  android:layout_weight="1"
                    />                      
</LinearLayout>
<TextView android:text="Next" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/gold"/>
</merge>

Please, help me to get the text below, I tried to put layout for textview but i can't get view what i need.anybody help me get it...


You're going to have to use the Merge Layout thats proposed in the Android Dev guide.

I have tried this out briefly using a GridView and TextView and has worked Pretty well.

here is my code for merge.xml :

<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android = "http://schemas.android.com/apk/res/android" >

<GridView 
       android:id = "@+id/gridview"
       android:layout_height = "fill_parent"
       android:layout_width = "fill_parent"
       android:columnWidth = "90dp"
       android:numColumns = "auto_fit"
       android:verticalSpacing = "10dp"
       android:horizontalSpacing = "10dp"
       android:stretchMode = "columnWidth"
       android:gravity = "center"
       android:background="#FFFFFF"
/>

<TextView
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="20dip"
        android:layout_gravity="center_horizontal|bottom"

        android:padding="12dip"

        android:background="#AA000000"
        android:textColor="#ffffffff"

        android:text="Want to see more?" />
</merge>

In your Activity class you should do the following:

 public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.merge);

        GridView gridView = (GridView) findViewById(R.id.gridview);
        gridView.setAdapter(new ImageAdapter(this));

note: ImageAdapter is a custom adapter used to display images. Now Using some random pictures you can generate the following view.

Obviously you would need to change the TextView to some sort of a button and maybe disable any scrolling in the GridView for your idea to work well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜