The best way to program buttons / images

I am creating something that will have a homepage close to the Google+ app for Android.

enter image description here

Having trouble finding the best way to do this? Should I create a button with text and set the background as an image? Should I create an image with text already programmed in the actual image, or should I program the text and image as buttons.

Any suggestions from you guys about past projects?

+4
source share
7 answers

Since I'm new to Android development, I might be wrong, but I suggest why not use the Grid View with every grid element that has a text view and image.

+2
source

You can use the button with the text anywhere, and then place the image for this button above the text (using android:drawableTop ) as follows:

 <Button android:id="@+id/imageButton" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Photos" android:drawableTop="@drawable/button_image" /> 

replacing buttton_image your actual image. If you want the image to be in a different position (i.e. below the text, etc.), Use:

 android:drawableLeft android:drawableRight android:drawableBottom 

That would be the way I would do it ...

+3
source

I suggest a layout: If you want to try something new in Android 4.0, you can try GridLayout for the layout, this can reduce the complexity of the nested layout, check out the GridLayout blog: http://android-developers.blogspot.com/2011/11 /new-layout-widgets-space-and-gridlayout.html

+1
source

You should write Buttons like this: http://developer.android.com/resources/articles/layout-tricks-merge.html

I usually use RelativeLayout, but that is not important.

Write myClass extends RelativeLayout class and inflate XML with

 LayoutInflater.from(context).inflate(R.layout.myCustomLayout, this, true); 

I think this is Google's best practice.

+1
source

use the regular button and set the value of the android parameter: drawableTop = "@ drawable / icon _...."

0
source

Having the text burned in you, the image is definitely not the way to go.

One option for you is GridView. You can also do this using a combination of the Image and scroll buttons. In my opinion, GridView is the best and includes the least amount of code with more flexibility.

0
source

Remember that you can replace the background image of a button with a list box.

0
source

Source: https://habr.com/ru/post/1387022/


All Articles