Android custom gridview layout (textview with imageview on top)

前端 未结 2 1885
名媛妹妹
名媛妹妹 2021-01-15 02:56

I\'m trying to work out how to create the layout for a gridview for my game. I have a gridview which will be the level selector. At the moment I have each gridview item as a

相关标签:
2条回答
  • 2021-01-15 03:16

    I would use a relative view!

    The basics would be, define your button background Bitmap/Drawable with the #1 on it, and then, for each button, have a layout with the copper, silver and gold stars. You can use android:layout_alignParentLeft="true" and android:layout_alignParentBottom="true" on the Copper start and base the other alignments off of that one. Then you just set the stars drawable based on if the star is toggled on or of.

    I'm going to use rough psuedo code here:

    <RelativeLayout android:id="button1">
      <ImageView android:id="copper_star" android:layout_alignParentLeft="true" android:layout_alignParentBottom="true" />
      <ImageView android:id="silver_star" android:layout_alignParentBottom="true" android:layout_rightOf="@id/copper_star"/>
       ...etc...
    </RelativeLayout>
    

    Once you've got it looking the way you want, you can see this discussion by Mark Murphy. He explains how to set the properties of a button to do what you'd like.

    0 讨论(0)
  • 2021-01-15 03:40

    I went with the un-technical 4 images in the end, it was simple and easy and there aren't any issues scrolling through the grid so it's all good.

    0 讨论(0)
提交回复
热议问题